Useful implementation of multi-servers udp tcp multi-get and binary protocol
Furthermore, it also testss data verification, expire-time verification, UDP, binary protocol, facebook test, replication test, multi-get and reconnection, etc. Memaslap manages network connections like memcached with libevent. Each connection keeps key size distribution, value size distribution, and command distribution by itself. Generates key and value more efficiently; key size distribution and value size distribution are configurable.
All the network events are managed by libevent as memcached. The network module of memaslap is similar to memcached. Libevent can ensure memaslap can handle network very efficiently. Memslap has the similar implementation of multi-threads to memcached. Memslap creates one or more self-governed threads; each thread is bound with one CPU core if the system testss setting CPU core affinity.
In addition, each thread has a libevent to manage the events of the network; each thread has one or more self-governed concurrencies; and each concurrency has one or more socket connections. Memslap can create thousands of socket connections, and each concurrency has tens of socket connections.
Each concurrency randomly or sequentially selects one socket connection from its socket connection pool to run, so memaslap can ensure each concurrency handles one socket connection at any given time. Users can specify the number of concurrency and socket connections of each concurrency according to their expected workload. In order to improve time efficiency and space efficiency, memaslap creates a random characters table with 10M characters.
All the suffixes useful implementation of multi-servers udp tcp multi-get and binary protocol keys and values are generated from this random characters table.
Memslap uses the offset in the character table and the length of the string to identify a string. It can save much memory. Each key contains two parts, a prefix and a suffix. In order to verify the data set before, memaslap need to ensure each key is unique, so it uses the prefix to identify a key. And memaslap has an algorithm to ensure that. It only generates enough objects to fill the task window default 10K objects of each concurrency.
Each object has the following basic information, key prefix, key suffix offset in the character table, key length, value offset in the character table, and value length.
In the work process, each concurrency sequentially or randomly selects an object from the window to do set operation or get operation. At the same time, each concurrency kicks objects out of its window and adds new object into it. Memslap uses libevent to schedule all the concurrencies of threads, and each concurrency schedules tasks based on the local task window. Memslap assumes that if each concurrency keeps the same key distribution, value distribution and commands distribution, from outside, memaslap keeps all the distribution as a whole.
Each task window includes a lot of objects, each object stores its basic information, such as key, value, expire time, and so on. At any time, all the objects in the window useful implementation of multi-servers udp tcp multi-get and binary protocol the same and fixed key and value distribution.
If an object is overwritten, the value of the object will be updated. Memslap verifies the data or expire-time according to the object information stored in the task window. Libevent selects which concurrency to handle based on a specific network event.
Then the concurrency selects which command get or set to operate based on the command distribution. If it needs to kick out an old object and add a new object, in order to keep the same key and value distribution, the new object must have the same key length and value length. If memcached server has two cache layers memory and SSDrunning memaslap with different window sizes can get different cache miss rates. If memaslap adds enough objects into the windows at the beginning, and the cache of memcached cannot store all the objects initialized, then memaslap will get some objects from the second cache layer.
It causes the first cache layer to miss. So the user can specify the window size to get the expected miss rate of the first cache layer. Because each thread is self-governed, memaslap can assign different threads to handle different memcached servers. This is just one of the ways in which memaslap tests multiple servers. The only limitation is that the number of servers cannot be greater than the number of threads.
The other way to test useful implementation of multi-servers udp tcp multi-get and binary protocol servers is for replication test. Each concurrency has one socket connection to each memcached server.
For the implementation, memaslap can set some objects to one useful implementation of multi-servers udp tcp multi-get and binary protocol server, and get these objects from the other servers. By default, Memslap does single get. If the user specifies multi-get option, memaslap will collect enough get commands and pack and send the commands together.
Because UDP is unreliable, dropped packages and out-of-order packages may occur. Memslap creates a memory buffer to handle these problems. Memslap tries to read all the response data of one command from the server and reorders the response data.
If some packages get lost, the waiting timeout mechanism can ensure half-baked packages will be discarded and the next command will be sent. The user must specify one server at least to run memaslap. The rest of the parameters have default values, as shown below:. The minimum key size is 16 bytes; the maximum key size is bytes.
The precision of proportion is 0. The proportion of distribution will be rounded to 3 decimal places. The minimum value size is 1 bytes; the maximum value size is 1M bytes. Currently, memaslap only testss set and get commands. The high performance of memaslap benefits from the special schedule of thread and concurrency. The default number of threads is 1; the default number of concurrency is If the system tests setting CPU affinity and the number of threads specified by the user is greater than 1, memaslap will try to bind each thread to useful implementation of multi-servers udp tcp multi-get and binary protocol different CPU core.
So if you want to get the best performance memaslap, it is better to specify the number of thread equal to the number of CPU cores. The number of threads specified by the user can also be less or greater than the number of CPU cores. Because of the limitation of implementation, the number of concurrencies could be the multiple of the number of threads. The memaslap performs very well, when used to test the performance of memcached servers.
Most of the time, the bottleneck is the network or the server. If for some reason the user wants to limit the performance of memaslap, there are two ways to do this:. Decrease the number of threads and concurrencies. This option allows the user to get the expected throughput. Most of the time, the user does not need to specify the window size. The default window size is 10k. For Schooner Memcached, the user can specify different window sizes to get different cache miss rates based on the test case.
If you use this utility to test the performance of Schooner Memcached, you can specify a proper window size to get the expected cache miss rate. The formula for calculating window size is as follows:. Memslap testss both data verification and expire-time verification. If the objects are gotten, memaslap will verify the expire-time and value. Memslap testss multi-servers based on self-governed thread.
There is a limitation that the number of servers cannot useful implementation of multi-servers udp tcp multi-get and binary protocol greater than the number of threads. Memslap assigns one thread to handle one server at least. The above command means that there are 6 threads, with each thread having 6 concurrencies and that threads 0 and 3 handle server 0 The user can start up several memaslap instances.
The user can run memaslap on different client machines to communicate with the same memcached server at the same. It is recommended that the user start different memaslap on different machines using the same configuration. The default memaslap runs with time mode. The default run time is 10 minutes.
If it times out, memaslap will exit. Do not specify both execute number mode and time mode at the same time; just specify one instead. Memslap will dump the statistics of the commands get and set at useful implementation of multi-servers udp tcp multi-get and binary protocol frequency of every 20 seconds.
Memslap by default does single get with TCP. Memslap also testss data verification and expire-time verification for multi-get.
Because of the different implementation of the ASCII protocol and binary protocol, there are some differences between the two. For TCP, memaslap does not reconnect the memcached server if socket connections are lost. If all the socket connections are lost or memcached server crashes, memaslap will exit. UDP is not testsed by the binary protocol because the binary protocol of memcached does not tests that.
The above command means that memaslap will do facebook test, each concurrency has socket TCP connections and one UDP socket. For replication test, the user must specify at least two memcached servers.
The above command means that there are 2 replication memcached servers, memaslap will set objects to both server 0 and server 1, get objects which are set to server 0 before from server 1, and also get objects which are set to server 1 before from server 0. If server 0 crashes, memaslap will only get objects from server 1. If server 0 comes back to life again, memaslap will reconnect server 0. If both server 0 and server 1 crash, memaslap will exit. Make sure that your system can tests opening thousands of files and creating thousands of sockets.