Giter Club home page Giter Club logo

locust-load-testing's Introduction

  1. How to send x no. of requests per second ?

Constant Throughput is about maintaining a consistent rate of requests sent to the target system.

you want to simulate a constant throughput of 100 requests per second (RPS). Here's how you can achieve that using the constant_throughput feature

Example 1:

from locust import User, task, constant
from datetime import datetime


class MyUser(User):

    wait_time=constant(0) # initial wait time
    constant_throughput = 100

    @task
    def login_url(self):
        # define your task here.
        print(datetime.now())

Example 2:

from locust import HttpUser, task, constant

class MyUser(HttpUser):
    @task
    def my_task(self):
        # Perform some HTTP request here
        self.client.get("/")

    wait_time = constant(0)  # Set initial wait time to 0
    constant_throughput = 100  # Desired throughput of 100 requests per second

  1. How to execute x no. of tasks per second ?

Constant Pacing is about simulating a consistent workload or a specific level of activity on the system under test, regardless of variations in task execution times or system load.

from locust import HttpUser, task, between, constant_pacing

class MyUser(HttpUser):
    @task
    def my_task(self):
        # Perform some HTTP request here
        self.client.get("/")

    wait_time = constant_pacing(2)  # Perform 2 tasks per second

  1. What is the difference between constant pacing and constant throughput ?

constant_pacing and constant_throughput are both features in Locust that regulate the rate at which tasks are executed, but they serve different purposes and operate in different ways:

Purpose:
    Constant Pacing: With constant_pacing, the focus is on maintaining a steady pace of task execution, typically measured in tasks per unit of time (e.g., tasks per second).
    Constant Throughput: On the other hand, constant_throughput aims to maintain a constant rate of requests sent to the target system, usually measured in requests per unit of time (e.g., requests per second).

Adjustment Mechanism:
    Constant Pacing: Locust adjusts the wait time between task executions to achieve the specified task rate, irrespective of how long each task takes to execute.
    Constant Throughput: Here, Locust adjusts the wait time between tasks based on the time taken to execute each task and maintain the desired rate of requests to the target system.

Use Cases:
    Constant Pacing: Useful when you want to simulate a consistent workload or a specific level of activity on the system under test, regardless of variations in task execution times or system load.
    Constant Throughput: Ideal for simulating a consistent load on the system by controlling the rate at which requests are sent to it, ensuring a stable number of requests per second.
  1. If there are 2 classes, how will you give the priority for one class to have more users ?

You can mention the weight attribute. Which will seggregate the users.


from locust import User, task, between

class MyWebUser(User):

    wait_time=between(1, 2)
    weight = 3

    @task
    def login_url(self):
        print("I am logging into Web Url")


class MyMobileUser(User):

    wait_time=between(1, 2)
    weight = 1

    @task
    def login_url(self):
        print("I am logging into Mobile Url")
  1. Can i do all the configuration using cli ?
locust -f headless.py -u 5 -r 1 -t 10s --headless --logfile .logfile --loglevel DEBUG

locust-load-testing's People

Contributors

syedjaferk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.