graph LR
Core_Orchestration["Core Orchestration"]
Environment_Management["Environment Management"]
Test_Runner["Test Runner"]
User_Behavior_Definition["User Behavior Definition"]
Client_Interfaces["Client Interfaces"]
Statistics_and_Reporting["Statistics and Reporting"]
RPC_Communication["RPC Communication"]
Web_User_Interface["Web User Interface"]
Event_System["Event System"]
Core_Orchestration -- "configures" --> Environment_Management
Core_Orchestration -- "initiates" --> Test_Runner
Core_Orchestration -- "initializes" --> Web_User_Interface
Core_Orchestration -- "uses" --> Statistics_and_Reporting
Core_Orchestration -- "uses" --> Event_System
Environment_Management -- "creates" --> Test_Runner
Environment_Management -- "initializes" --> Statistics_and_Reporting
Environment_Management -- "initializes" --> Web_User_Interface
Environment_Management -- "uses" --> User_Behavior_Definition
Environment_Management -- "uses" --> Event_System
Test_Runner -- "interacts with" --> User_Behavior_Definition
Test_Runner -- "reports to" --> Statistics_and_Reporting
Test_Runner -- "communicates with" --> RPC_Communication
Test_Runner -- "uses" --> Event_System
User_Behavior_Definition -- "utilizes" --> Client_Interfaces
User_Behavior_Definition -- "can trigger" --> Event_System
Client_Interfaces -- "report metrics to" --> Statistics_and_Reporting
Client_Interfaces -- "fire events to" --> Event_System
Statistics_and_Reporting -- "receives data from" --> Client_Interfaces
Statistics_and_Reporting -- "receives data from" --> Test_Runner
Statistics_and_Reporting -- "is used by" --> Web_User_Interface
Statistics_and_Reporting -- "uses" --> Event_System
RPC_Communication -- "is used by" --> Test_Runner
RPC_Communication -- "interacts with" --> Event_System
Web_User_Interface -- "retrieves data from" --> Test_Runner
Web_User_Interface -- "retrieves data from" --> Statistics_and_Reporting
Web_User_Interface -- "uses" --> Event_System
Event_System -- "is used by" --> Core_Orchestration
Event_System -- "is used by" --> Environment_Management
Event_System -- "is used by" --> Test_Runner
Event_System -- "is used by" --> User_Behavior_Definition
Event_System -- "is used by" --> Client_Interfaces
Event_System -- "is used by" --> Statistics_and_Reporting
Event_System -- "is used by" --> RPC_Communication
Event_System -- "is used by" --> Web_User_Interface
click Core_Orchestration href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/locust/Core Orchestration.md" "Details"
click Environment_Management href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/locust/Environment Management.md" "Details"
click Test_Runner href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/locust/Test Runner.md" "Details"
click User_Behavior_Definition href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/locust/User Behavior Definition.md" "Details"
click Client_Interfaces href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/locust/Client Interfaces.md" "Details"
click Statistics_and_Reporting href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/locust/Statistics and Reporting.md" "Details"
click RPC_Communication href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/locust/RPC Communication.md" "Details"
click Web_User_Interface href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/locust/Web User Interface.md" "Details"
click Event_System href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/locust/Event System.md" "Details"
The Locust architecture is designed for distributed load testing, centered around a Core Orchestration component that manages the test lifecycle from argument parsing to initiating the test run. It leverages an Environment Management component to configure the test environment, including user classes and event handling. The core of the execution is handled by the Test Runner, which manages virtual users and coordinates distributed testing through RPC Communication with worker nodes. User behavior is defined by the User Behavior Definition component, which utilizes various Client Interfaces (HTTP, FastHTTP, etc.) to interact with the system under test. All interactions and performance metrics are captured by the Statistics and Reporting component, which provides data for the Web User Interface for real-time monitoring and reporting. A central Event System facilitates decoupled communication between all these components, enabling a flexible and extensible architecture.
This component serves as the central control unit of Locust. It is responsible for parsing command-line arguments, initializing the test environment, orchestrating the overall test execution flow (including starting and stopping runners), and managing global application settings. It also handles interactive input for runtime control.
Related Classes/Methods:
locust.locust.main:main(160:687)locust.locust.main:create_environment(75:102)locust.locust.main:merge_locustfiles_content(105:157)locust.locust.argument_parser:parse_locustfile_option(287:338)locust.locust.argument_parser:get_locustfiles_locally(341:347)locust.locust.argument_parser:parse_options(871:876)locust.locust.argument_parser:get_parser(860:868)locust.locust.argument_parser:setup_parser_arguments(439:857)locust.locust.argument_parser:default_args_dict(879:885)locust.locust.argument_parser:ui_extra_args_dict(896:915)locust.locust.input_events.UnixKeyPoller:__init__(32:38)locust.locust.input_events.WindowsKeyPoller:__init__(51:62)locust.locust.input_events:get_poller(91:95)locust.locust.input_events:input_listener(98:119)
This component encapsulates the Locust test environment's configuration and state. It manages user classes, event hooks, host settings, and provides methods for creating different types of test runners and the web UI. It acts as a central repository for test-specific settings.
Related Classes/Methods:
locust.locust.env.Environment:__init__(23:114)locust.locust.env.Environment:_create_runner(116:130)locust.locust.env.Environment:create_local_runner(132:136)locust.locust.env.Environment:create_master_runner(138:150)locust.locust.env.Environment:create_worker_runner(152:166)locust.locust.env.Environment:create_web_ui(168:209)locust.locust.env.Environment:_filter_tasks_by_tags(229:253)locust.locust.env.Environment:update_user_class(211:223)
This component is responsible for managing the lifecycle of virtual users and coordinating the load test execution. It includes implementations for local, master, and worker modes, handling user spawning, stopping, and distributing users across nodes in a distributed setup.
Related Classes/Methods:
locust.locust.runners.Runner:__init__(86:128)locust.locust.runners.Runner:spawn_users(199:230)locust.locust.runners.Runner:start_shape(309:322)locust.locust.runners.Runner:shape_worker(324:361)locust.locust.runners.Runner:stop(363:397)locust.locust.runners.Runner:quit(399:404)locust.locust.runners.LocalRunner:__init__(430:449)locust.locust.runners.LocalRunner:_start(451:530)locust.locust.runners.LocalRunner:start(532:546)locust.locust.runners.LocalRunner:stop(548:551)locust.locust.runners.LocalRunner:send_message(553:566)locust.locust.runners.DistributedRunner:__init__(570:572)locust.locust.runners.WorkerNodes:ready(603:604)locust.locust.runners.WorkerNodes:spawning(607:608)locust.locust.runners.WorkerNodes:running(611:612)locust.locust.runners.WorkerNodes:missing(615:616)locust.locust.runners.MasterRunner:__init__(644:692)locust.locust.runners.MasterRunner:cpu_log_warning(716:721)locust.locust.runners.MasterRunner:start(723:833)locust.locust.runners.MasterRunner:stop(859:892)locust.locust.runners.MasterRunner:quit(894:901)locust.locust.runners.MasterRunner:check_stopped(903:909)locust.locust.runners.MasterRunner:heartbeat_worker(911:948)locust.locust.runners.MasterRunner:reset_connection(950:957)locust.locust.runners.MasterRunner:client_listener(959:1160)locust.locust.runners.MasterRunner:send_message(1174:1189)locust.locust.runners.WorkerRunner:__init__(1204:1249)locust.locust.runners.WorkerRunner:spawning_complete(1251:1260)locust.locust.runners.WorkerRunner:start_worker(1267:1295)locust.locust.runners.WorkerRunner:heartbeat(1297:1314)locust.locust.runners.WorkerRunner:heartbeat_timeout_checker(1316:1321)locust.locust.runners.WorkerRunner:reset_connection(1323:1329)locust.locust.runners.WorkerRunner:worker(1331:1420)locust.locust.runners.WorkerRunner:stats_reporter(1422:1428)locust.locust.runners.WorkerRunner:logs_reporter(1430:1447)locust.locust.runners.WorkerRunner:send_message(1449:1458)locust.locust.runners.WorkerRunner:_send_stats(1460:1463)locust.locust.runners.WorkerRunner:_send_logs(1465:1466)locust.locust.runners.WorkerRunner:connect_to_master(1468:1488)locust.locust.dispatch.UsersDispatcher:__init__(70:119)locust.locust.dispatch.UsersDispatcher:__next__(132:136)locust.locust.dispatch.UsersDispatcher:_dispatcher(152:183)locust.locust.dispatch.UsersDispatcher:new_dispatch(185:215)locust.locust.dispatch.UsersDispatcher:add_worker(217:228)locust.locust.dispatch.UsersDispatcher:remove_worker(230:242)locust.locust.dispatch.UsersDispatcher:_prepare_rebalance(244:268)locust.locust.dispatch.UsersDispatcher:_distribute_users(339:368)locust.locust.dispatch.UsersDispatcher:_user_gen(370:388)locust.locust.runners.Runner:stop_users(232:281)
This component defines the actions and behavior of virtual users during a load test. It includes the core User and TaskSet classes, which encapsulate the tasks to be executed, wait times between tasks, and mechanisms for task interruption.
Related Classes/Methods:
locust.locust.user.users.UserMeta:__new__(35:46)locust.locust.user.users.User:run(143:158)locust.locust.user.users.User:wait(160:170)locust.locust.user.users.HttpUser:__init__(259:276)locust.locust.user.inspectuser:print_task_ratio(11:16)locust.locust.user.inspectuser:print_task_ratio_json(19:26)locust.locust.user.inspectuser:_print_task_ratio(44:50)locust.locust.user.inspectuser:get_ratio(53:63)locust.locust.user.inspectuser:_get_task_ratio(66:81)locust.locust.user.task:task(39:39)locust.locust.user.task:tag(98:134)locust.locust.user.task:filter_tasks_by_tags(168:204)locust.locust.user.task.TaskSetMeta:__new__(213:215)locust.locust.user.task.TaskSet:run(323:370)locust.locust.user.task.TaskSet:execute_next_task(372:373)locust.locust.user.task.TaskSet:wait_time(410:427)locust.locust.user.task.TaskSet:wait(429:445)locust.locust.user.task.TaskSet:interrupt(450:457)locust.locust.user.wait_time:constant_throughput(60:83)locust.locust.user.sequential_taskset.SequentialTaskSet:__init__(57:59)locust.locust.user.sequential_taskset.SequentialTaskSet:get_next_task(61:66)locust.locust.user.wait_time:constant(18:27)
This component provides the actual client implementations for making requests to the target system. It includes generic HTTP clients and specialized clients for various protocols (e.g., FastHTTP, OpenAI, MongoDB, PostgreSQL). It handles request building, sending, response processing, and integrates with the statistics collection.
Related Classes/Methods:
locust.locust.clients.HttpSession:__init__(89:115)locust.locust.clients.HttpSession:request(134:228)locust.locust.clients.HttpSession:_send_request_safe_mode(230:245)locust.locust.clients.HttpSession:get(247:252)locust.locust.clients.HttpSession:options(254:264)locust.locust.clients.HttpSession:head(266:276)locust.locust.clients.HttpSession:post(278:286)locust.locust.clients.HttpSession:put(288:297)locust.locust.clients.HttpSession:patch(299:308)locust.locust.clients.HttpSession:delete(310:319)locust.locust.clients.ResponseContextManager:__exit__(345:389)locust.locust.clients.ResponseContextManager:success(394:408)locust.locust.clients.ResponseContextManager:failure(410:429)locust.locust.clients:_missing_catch_response_True(443:446)locust.locust.contrib.fasthttp.FastHttpSession:__init__(107:146)locust.locust.contrib.fasthttp.FastHttpSession:_send_request_safe_mode(155:175)locust.locust.contrib.fasthttp.FastHttpSession:request(177:293)locust.locust.contrib.fasthttp.FastHttpSession:delete(295:297)locust.locust.contrib.fasthttp.FastHttpSession:get(299:301)locust.locust.contrib.fasthttp.FastHttpSession:iter_lines(303:312)locust.locust.contrib.fasthttp.FastHttpSession:head(314:316)locust.locust.contrib.fasthttp.FastHttpSession:options(318:320)locust.locust.contrib.fasthttp.FastHttpSession:patch(322:326)locust.locust.contrib.fasthttp.FastHttpSession:post(328:332)locust.locust.contrib.fasthttp.FastHttpSession:put(334:338)locust.locust.contrib.fasthttp.FastHttpUser:__init__(391:417)locust.locust.contrib.fasthttp.FastHttpUser:rest(420:465)locust.locust.contrib.fasthttp.FastHttpUser:rest_(468:477)locust.locust.contrib.fasthttp.FastResponse:success(568:571)locust.locust.contrib.fasthttp.FastResponse:failure(573:576)locust.locust.contrib.fasthttp.LocustUserAgent:_urlopen(619:625)locust.locust.contrib.fasthttp.LocustUserAgent:_verify_status(627:630)locust.locust.contrib.fasthttp.ResponseContextManager:__exit__(661:686)locust.locust.contrib.fasthttp.ResponseContextManager:success(691:705)locust.locust.contrib.fasthttp.ResponseContextManager:failure(707:726)locust.locust.contrib.oai.OpenAIUser:__init__(71:73)locust.locust.contrib.mongodb.MongoDBUser:__init__(36:38)locust.locust.contrib.postgres.PostgresUser:__init__(40:42)locust.locust.contrib.postgres.PostgresUser:on_stop(44:45)
This component is responsible for collecting, aggregating, and presenting performance statistics from the load test. It tracks request metrics (response times, failures, RPS), manages error reports, and generates various output formats like console summaries, CSV files, and HTML reports.
Related Classes/Methods:
locust.locust.stats.EntriesDict:__missing__(178:182)locust.locust.stats.RequestStats:__init__(190:201)locust.locust.stats.RequestStats:log_request(223:225)locust.locust.stats.RequestStats:log_error(227:237)locust.locust.stats.RequestStats:reset_all(245:253)locust.locust.stats.RequestStats:clear_all(255:262)locust.locust.stats.StatsEntry:__init__(278:328)locust.locust.stats.StatsEntry:reset(330:345)locust.locust.stats.StatsEntry:log(347:361)locust.locust.stats.StatsEntry:median_response_time(419:433)locust.locust.stats.StatsEntry:current_rps(436:444)locust.locust.stats.StatsEntry:current_fail_per_sec(447:455)locust.locust.stats.StatsEntry:extend(482:524)locust.locust.stats.StatsEntry:unserialize(530:540)locust.locust.stats.StatsEntry:get_stripped_report(542:548)locust.locust.stats.StatsEntry:__str__(581:582)locust.locust.stats.StatsEntry:get_response_time_percentile(584:591)locust.locust.stats.StatsEntry:get_current_response_time_percentile(593:635)locust.locust.stats.StatsEntry:percentile(637:647)locust.locust.stats.StatsEntry:_cache_response_times(649:667)locust.locust.stats.StatsEntry:to_dict(669:691)locust.locust.stats.StatsError:create_key(719:721)locust.locust.stats.StatsError:serialize(744:753)locust.locust.stats.StatsError:unserialize(756:757)locust.locust.stats.StatsError:to_dict(759:765)locust.locust.stats:setup_distributed_stats_event_listeners(786:810)locust.locust.stats:print_stats(813:816)locust.locust.stats:print_percentile_stats(843:846)locust.locust.stats:get_percentile_stats_summary(849:871)locust.locust.stats:print_error_report(874:877)locust.locust.stats:stats_printer(892:898)locust.locust.stats:update_stats_history(905:924)locust.locust.stats:stats_history(927:936)locust.locust.stats.StatsCSV:__init__(942:974)locust.locust.stats.StatsCSV:requests_csv(984:987)locust.locust.stats.StatsCSV:_requests_data_rows(989:1010)locust.locust.stats.StatsCSV:failures_csv(1012:1014)locust.locust.stats.StatsCSV:_failures_data_rows(1016:1025)locust.locust.stats.StatsCSV:exceptions_csv(1027:1029)locust.locust.stats.StatsCSVFileWriter:__init__(1042:1082)locust.locust.stats.StatsCSVFileWriter:__call__(1084:1085)locust.locust.stats.StatsCSVFileWriter:stats_writer(1087:1128)locust.locust.stats.StatsCSVFileWriter:_stats_history_data_rows(1130:1167)locust.locust.stats:validate_stats_configuration(1201:1224)locust.locust.html:get_html_report(34:110)
This component facilitates inter-process communication (IPC) between Locust master and worker nodes in a distributed testing setup. It uses ZeroMQ for reliable message passing, enabling the master to send commands (e.g., spawn, stop) and workers to send reports (e.g., stats, heartbeats, exceptions).
Related Classes/Methods:
locust.locust.rpc.zmqrpc.BaseSocket:send(25:29)locust.locust.rpc.zmqrpc.BaseSocket:send_to_client(32:36)locust.locust.rpc.zmqrpc.BaseSocket:recv(38:46)locust.locust.rpc.zmqrpc.BaseSocket:recv_from_client(48:60)locust.locust.rpc.zmqrpc.Server:__init__(78:87)locust.locust.rpc.zmqrpc.Client:__init__(91:94)locust.locust.rpc.protocol.Message:unserialize(45:47)
This component provides a web-based interface for controlling and monitoring Locust load tests. It allows users to start/stop tests, view real-time statistics, manage user classes, and download reports through a browser. It interacts with the test runner and statistics components to display relevant information.
Related Classes/Methods:
locust.locust.web.WebUI:__init__(121:588)locust.locust.web.WebUI:start_server(605:622)locust.locust.web.WebUI:update_template_args(656:746)locust.locust.html:get_html_report(34:110)locust.locust.web.WebUI:swarm(130:217)locust.locust.web.WebUI:stop(624:628)locust.locust.web.WebUI:request_stats(300:344)locust.locust.web.WebUI:stats_report(240:255)
This foundational component provides a publish-subscribe mechanism for event-driven communication throughout the Locust application. It allows various components to register listeners for specific events (e.g., request completion, test start/stop, worker connection) and fire events to notify other parts of the system, promoting loose coupling.
Related Classes/Methods:
locust.locust.event.EventHook:measure(57:89)locust.locust.event.DeprecatedEventHook:__init__(93:95)locust.locust.event.DeprecatedEventHook:add_listener(97:99)locust.locust.event.Events:__init__(270:278)locust.locust.event.EventHook:add_listener(33:35)locust.locust.event.EventHook:fire(40:54)