I often use wrk to conduct simple stress tests on interfaces at work. Recently, the test interface at work requires signature verification of parameters. Taking this opportunity, I plan to study wrk carefully;
The wrk command options are shown in the figure below:
Example:
The -s option specifies the lua script file. Here is an example of a script:
You can see You can call third-party libraries in Lua scripts and set parameters dynamically, and wrk is based on epoll and has powerful performance;
wrk is open source, its source code address is /wg/wrk, and is implemented in C language;
p>
wrk defines the global variable wrk, and provides the following functions for expansion:
The implementation of wrk is very simple, and the main source files include:
Let’s take a closer look at what wrk is How to implement:
wrk has several important data structures, including thread and connection:
wrk initialization logic: