PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 1, 2022

[FIXED] How to increase API server performance?

 August 01, 2022     api, locust, performance, python, vps     No comments   

Issue

I am testing my server performance using Locust.

API and server was configures as per this tutorial: https://medium.com/swlh/python-with-docker-compose-fastapi-part-2-88e164d6ef86

Here is my Locust load testing code:

from locust import HttpUser, TaskSet, task, between

class FastApi(TaskSet):
    @task(1)
    def user_by_name(self):
        self.client.get(
            url="/user/?first_name=Name"
            )

class ApiLoadTest(HttpUser):
    tasks = [FastApi]
    host = "http://vps1234.vps.ovh.net:8000"
    stop_timeout = 20
    wait_time = between(1, 3)

I setup Locust as below:

  • Number of total users to simulate: 1000
  • Spawn rate: 100

For now Locust is showing below statistics:

  • Current RPS: 226
  • Average (ms): 2704
  • Max (ms): 5200

Server (OVH):

  • 1 vCore
  • 2 GB RAM
  • 20 GB SSD
  • 100 Mbps

My questions is if low performance is caused by not really good VPS, or I made some mistake in my load testing code? I am wondering if only solution to improve server performance to achieve some about 100 ms average response is to upgrade VPS to have more CPUs/RAM/Mbps?

Kind regards


Solution

You need to look for performance statistics for your VPS to answer this question.

Basic things to look at are CPU, RAM and disk usage during your load tests.

The other limitation may be the client machine itself. But for 1000 users and above script it should be ok



Answered By - TestMechanic
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing