-
Notifications
You must be signed in to change notification settings - Fork 1
PerfTest
This article describes the tool for performance and stress testing. It is located in the "tools/perfTest/" directory. The tool creates a given number of worker threads with each one creating a given number of client instances. Each of the instances establishes connection to the given game server and works through a script file, showing statistics every 10 seconds. After the tool finishes its work, it prints some useful statistics and writes log files that have detailed response time for each message.
Before starting the testing you will need to create test users en masse. This is done with a tool located in "tools/userCreate/" directory. This tool inserts the needed user records into database. User parameters will be copied from the proto-user.
The configuration file ("script.cfg") is simple enough:
Configuration variable | Description |
---|---|
database.host | Database host. |
database.name | Database name. |
database.password | Database password. |
database.port | Database port. |
database.user | Database user. |
user.amount | Amount of users to create. |
user.prefix | User name prefix. The resulting user name will be <prefix>.<user ID>
|
user.startID | Starting user ID. |
The configuration file for the perfTest tool is called "script.cfg" and can contain the following variables:
Configuration variable | Description |
---|---|
script.threads | Amount of worker threads. |
server.logState | (0/1) If enabled, will log instance states every 10 seconds. |
server.printLog | (0/1) If enabled, log will be printed out to stdout. |
server.writeLog | (0/1) If enabled, log will be written to "log.txt" logfile. |
thread.script | Script file name for this thread. |
thread.server.host | Game server host for this thread. |
thread.server.port | Game server port for this thread. |
thread.user.amount | Amount of client instances for this thread. |
thread.user.prefix | User name prefix for this thread. The resulting user name will be <prefix>.<user ID> . |
thread.user.randomID | (0/1) If enabled, will make a random user ID instead of starting from "startID" and going up. |
thread.user.startID | Starting user ID for this thread. |
The script files contains lines starting with control sequences that can send messages, receive responses and wait for a given number of seconds. The messages are encoded in JSON format in script file.
Script example:
// user registration
send {"messageType":"user.register","name":"$name","gender":1,"networkid":"$networkid","networktype":"FB"}
recv
// user login
send {"messageType":"user.login","name":"$name","networkid":"$networkid","password":"","lang":"en"}
recv
recv
pause 5
// initial info get
send {"messageType":"shop.get"}
recv
send {"messageType":"user.info"}
recv
Note the strings $name
and $networkid
. These are special variables that are concatenated from configuration file variables as "user name prefix" + "user ID".
Also note the double "recv" token after the login message. By default the "user.login" message will, of course, send one response. But in some of our projects we send multiple responses through separate login hooks (for legacy reasons). In that case the response will be marked as "user.login more" in log and it's time will be calculated from the end of the previous server response.
- "pause" token pauses script execution for a given number of seconds.
- "recv" token receives the server response.
- "send" token sends a message to the server.
After finishing the run the tool will create full message logs for each of the worker threads in CSV format. Each line will have unique instance ID, timestamp of receiving message, message type, calculated time from the start of message send to the end of message response in milliseconds.
Partial example:
id,timestamp,type,time
0,1466008247.5449,user.register,105.38792610168
0,1466008248.94724,user.login,51.48186683655
0,1466008249.05072,user.login more,23.486061096191
0,1466008254.12312,shop.get,39.1488075256348
0,1466008254.15916,user.info,31.6970348358154
0,1466008254.1765,user.ping,16.002893447876
0,1466008259.47345,level.start,89.543867111206
0,1466008259.85986,shop.buy,85.707855224609