By: Akhilesh NS

Odoo Load Balancing using Locust

    Locust is an easy-to-use, distributed, fresh open source performance framework written in Python. It is intended for load-testing websites (or other systems) and figuring about how many concurrent users a system can handle. It is based on the MIT license.  

Locust stress Odoo with maximum concurrent users. Locust has a neat and beautiful web interface enabling users to monitor the request failure rate (percentage) at different load levels. Also, it provides three basic graphical representations for Total Request per second, Response Time (ms) and Number of users. The failure exception logs are also available in locust UI. After finishing a test, the user can download CSV files for Request Statics, Response time Distribution and Exceptions. 

Configuration of Locust with Odoo

1. Install locust, Odoo Locust and other dependencies :

It is better to run locust with python 2.7. Python 3 has some issues with Odoo Locust package and its dependencies. 

pip install locustio OdooLocust openerp-client-lib
2. Create your test with locust

Here I am stressing odoo with two simple tasks.

A. Read Partner ID’s
B. Read Product ID’s

Here is the seller_taskset.py file

from locust import  TaskSet, task
from OdooLocust import OdooLocust
class SellerTaskSet(TaskSet):
“””All tasks are defined in each function”””
def read_partners(self):
cust_model = self.client.get_model('res.partner')
cust_ids = cust_model.search([])
prtns = cust_model.read(cust_ids)
def read_products(self):
prod_model = self.client.get_model('product.product')
ids = prod_model.search([])
prods = prod_model.read(ids)
class Seller(OdooLocust):
“””Server credentials are given gere”””
host = ""
database = "test"
port = 8015
login = "admin"
password = "admin"
protocol = "jsonrpc"
user_id = -1
min_wait = 100
max_wait = 1000
weight = 3
task_set = SellerTaskSet
1) @task takes an optional weight argument that can be used to specify the task’s execution ratio. In the above example, task1 will be executed twice as much as task2
2) max_wait = 1000
Maximum weighting time between the execution of locust task
3) min_wait = 100
Minimum weighting time between the execution of locust task
4) TaskSet class defines the execution behavior of this locust
5) weight = 3
The probability of locust being chosen. The higher the weight, the greater is the chance of being chosen. 

3. Run seller_taskset.py file by

locust -f seller_taskset.py Seller


Now got to on any web browser.


In the above interface, locust needs two inputs to start stressing odoo.

1. Amount of users to simulate 
2. Hatch rate: how quickly want to spawn the users


"Number of users to simulate" = 30
"Hatch rate" (user spawned / second) = 3

When we start the load test with this configuration, locust will spawn 3 new users for every second until it fulfills the total number of users to simulate (which is 30 in this case). After 10 seconds, you will have a swarm of 30 simulated users.

To control the no. of request per second, you will need to set the max_wait accordingly. 

Locust test for the above example is given below.








Leave a comment


Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kerala, India - 673635


Cybrosys Limited
2 Sheen Road,
Richmond, London
England - TW9 1AE


Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.


Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message