Openfire Configuration:
After openfire is installed in Ubuntu, the performance is extremely low, and the stress test can only reach 4000 online users.
Step 1 modify the openfire Runtime Environment
Run PS-Aux | grep openfire to view the openfire service. The startup command is as follows:
/Usr/lib/JVM/java-7-openjdk-amd64/JRE/bin/Java-server-dopenfirehome =/usr/share/openfir-dopenfire. lib. dir =/usr/share/openfire/lib-classpath/usr/share/openfire/lib/startup. jar-Jar/usr/share/openfire/lib/startup. jar
First, we can see that the JVM used here is provided by openjdk, and the performance is not good. Therefore, kill the process first (this operation is not required if it is not used by openjdk ). Kill and execute PS to check if the change has actually been removed. then switch to root and run/etc/init. d/openfire start. Check again that the JDK path has been switched to your own, provided that JDK has been configured.
/Home/David/Java/jdk1.8.0 _ 05 // bin/Java-server-dopenfirehome =/usr/share/openfire-dopenfire. lib. dir =/usr/share/openfire/lib-classpath/usr/share/openfire/lib/startup. jar-Jar/usr/share/openfire/lib/startup. jar
Step 2 epoll mode modification:
To improve performance, you need to change the startup command to NiO to support epoll. You need to modify the/etc/init. d/openfire script file. Change daemon_opts
Authorization = "$ daemon_opts-server-xms3072m-xmx4096m-djava. NiO. channels. SPI. selectorprovider = sun. NiO. Ch. epollselectorprovider-dopenfirehome =$ {daemon_dir }\
-Dopenfire. Lib. dir =$ {daemon_lib}-classpath $ {daemon_lib}/startup. Jar \
-Jar $ {daemon_lib}/startup. Jar"
-Djava. NiO. channels. SPI. selectorprovider = sun. NiO. Ch. epollselectorprovider is added. Note that the JVM memory usage is also modified here.
Tsung stress testing:
Step 1 modify the maximum number of opened files
When Tsung is installed on a host without any modification for stress testing, it is found that at most 1000 of the online users can be reached. The error is that emfile executes ulimit-N to view as 1024, which means too many files are opened, the default value is 1024. Run the ulimit-N 65535 command. This 65535 value is just a big number. For long-term modification, You need to modify/etc/security/limits. conf and add:
Root-nofile 65535
Note: root must be clearly written as root and cannot be used *.
Step 2 modify the port range
Continue the stress test and find that the pressure will not go up when it reaches about 28000. The error is eaddrinuse. In this case, the port is insufficient. You need to modify/etc/sysctl. conf and add:
Net. ipv4.ip _ local_port_range = 1024 65000
Increase the number of ports that can be allocated to more than. Execute sysctl-P to take effect immediately. Use sysctl-A | grep range to check whether the range has changed. Now we can do another stress test to find that the number of online users has reached.
Step 3: Tsung Cluster
One machine has reached the limit when simulating 6 million users online. At this time, multiple Tsung testing machines are required for testing. The same Erlang and Tsung versions must be installed on each test server, and the root user can log on without a password (root may not be required ). In addition, note that the machine name cannot use LC-optex or the like, and the "-" in the middle cannot be connected in ERL, so it is OK to directly name kf2lc.
Take the three test machines (which can use the bridge mode of virtual machines) as an example. Assume the machine names are kf2test01, kf2test02, and kf2test03, And the IP addresses are 172.28.23.180, 172.28.23.181, and 172.28.2.
Add:
172.28.23.180 kf2test01
172.28.23.181 kf2test02
172.28.23.182 kf2test03
After kf2test01 is switched to root, run SSH kf2test02. If you do not have a password to log on, it will be OK. If you are prompted to enter a password, you need to log on without a password. Other machines perform the same connection test to ensure that they can log on to each other without a password.
At this time, the maximum number of files on the remote server viewed by ulimit-N is still 1024. As a result, the slave server of the cluster can only create up to 1000 simulated users. You need to add the following to/etc/profile:
Ulimit-shn 65535
Run ERL to test whether the cluster is successful before Tsung tests the stress. Run ERL in shell:
> Erl-RSH ssh-sname root-setcookie mycookie
Eshell v5.8.5 (abort with ^ g)
([Email protected]) 1> slave: Start (kf2test02, root, "-setcookie mycookie ").
If OK is returned, the operation is successful, as shown below:
{OK, [email protected]}
If the cluster fails, the cluster does not respond for half a day and {error, timeout} is displayed }.
After configuring Tsung, modify the configuration of jabber. xml:
<Clients>
<Client host = "kf2test01" use_controller_vm = "false" maxusers = "60000">
<IP value = "172.28.23.180"/>
</Client>
<Client host = "kf2test02" use_controller_vm = "false" maxusers = "60000">
<IP value = "172.28.23.181"/>
</Client>
<Client host = "kf2test03" use_controller_vm = "false" maxusers = "60000">
<IP value = "172.28.23.182"/>
</Client>
</Clients>
Then run Tsung-F jabber. XML to test the cluster pressure. In this way, the testing theoretically can reach million simulated users. The following is the test output report:
Some Thoughts on openfire performance optimization:
1. Now the number of concurrent connections on the server is more than 1400. By adding the Connection Manager to achieve high concurrency, The frontend needs to be added to the load balancing server (load banlancer) or DNS to achieve shunting.
2. openfire connects to the database directly, and memcached must be added as the database cache.
3. The openfire cluster is said to have performance problems and needs to find the bottleneck.
4. The server should be elected as centos instead of ubuntu.
Openfire performance optimization and stress testing Summary