Performance Tuning
Capacity Planning
This section provides recommendations to evaluate server hardware and memory requirements for your Go server. It also highlights some configurations which need to be taken care of when scaling Go.
Minimum server requirements
Scaling Go
As the number of pipelines, agents and concurrent users increase in your setup, Go server may have to be scaled up by adding more memory and cores.
If you have questions or have custom requirements, please contact support@thoughtworks.com to help with capacity planning for Go server
Things to Remember
- Edit /etc/security/limits.conf and add the lines: * soft nofile 1024 * hard nofile 65535
- Edit /etc/pam.d/login, adding the line: session required /lib/security/pam_limits.so
- The system file descriptor limit can be increased by setting "fs.file-max" in the file "/etc/sysctl.conf". To set the limit to 65535 use echo "fs.file-max = 65535" >> /etc/sysctl.conf
Tuning your JVM
Ensure that the latest JVM is used always, as there are major performance improvements with every release.
Storage
Troubleshooting
Enable GC Logging
An easy way to check the memory usage, heap size (initial and over time) and GC metrics of the application is by turning on GC logging. GC logging can be enabled using the following JVM arguments while starting the application (Note: the log file specified as file is reset each time the VM starts.)
-verbose:gc -Xloggc:file -XX:+PrintGCTimeStamps
In case of the Go server, these arguments will have to be added in the script that starts the Go jar:Using JConsole
JConsole is a graphical monitoring tool to monitor Java Virtual Machine (JVM) which comes as part of the JDK installation. It can be used to monitor the current state of a process without much overhead. If the Go server's performance is slow, some metrics can be immediately analysed using jconsole.
Since jconsole is a graphical tool, make sure you have an access to display, when running the following command. That is, use 'ssh -X' or VNC if Go is on linux. Use remote desktop if the Go server is on windows.
$ jconsoleSelect the local process 'go.jar' when the jconsole GUI opens up. This shows the current heap memory usage, threads, cpu usage etc. Screenshots of the VM Summary and the overview page can be taken to be sent to the Go Support team, if required.
Please note that in case of linux, jconsole will have to be started as 'go' user. In Windows, starting the process as administrator should suffice.
CPU and memory profiling
Yourkit java profiler is a recommended tool for profiling the CPU and memory of the GO Server.
To start using yourkit, download the latest version of the Yourkit java profiler from http://www.yourkit.com/download/index.jsp. Unpack to {yourkit_profiler_directory} The following steps will enable the Go server to pick up the yourkit profiler agent and enable us to take memory and cpu snapshots.
For Linux
- Create a symlink for libyjpagent.so file to /usr/lib/yourkit folder. When the Go server starts up, it looks at this folder to see if it needs to start with profiling
enabled or not. If you want to change the default path of the yourkit agent, you can edit server.sh at /usr/share/go-server/server.sh
$ sudo ln -s {yourkit_profiler_directory}/bin/linux-x86-32/libyjpagent.so /usr/lib/yourkit/libyjpagent.soFor 64-bit JVM, the command is:$ sudo ln -s {yourkit_profiler_directory}/bin/linux-x86-64/libyjpagent.so /usr/lib/yourkit/libyjpagent.so - Restart the server after this, and the yourkit agent should get picked up by the server VM. Let the server start up and agents get registered.
For Windows
- By default, Go server looks for the yourkit profiler agent yjpagent.dll in the location C:\yjpagent.dll. Therefore, copy the file yjpagent.dll (which is the yourkit profiler agent) from '{yourkit_profiler_directory}\bin\win32' to C:\yjpagent.dll. Copy the file from '{yourkit_profiler_directory}\bin\win64' if you are using 64 bit JVM.
- To change the above mentioned default location: define environment variable YOURKIT_PATH with value equal to location of yjpagent.dll.
Use the following steps to take profile the application and take snapshots. The {hostname} mentioned here is the hostname of the Go Server. In most cases, it would be 'localhost'. The value of {port} is 6133, because Go starts the yjpagent on port 6133.
- To start profiling, run:
$ java -jar {yourkit_profiler_directory}/lib/yjp-controller-api-redist.jar {hostname} {port} start-cpu-sampling$ java -jar {yourkit_profiler_directory}/lib/yjp-controller-api-redist.jar {hostname} {port} start-monitor-profilingIf memory allocation profiling is also required:$ java -jar {yourkit_profiler_directory}/lib/yjp-controller-api-redist.jar {hostname} {port} start-alloc-recording-adaptive - Let the server run for some time till you start seeing performance problems. 30 mins of snapshot should give us enough data.
- To capture the snapshot - Run:
$ java -jar {yourkit_profiler_directory}/lib/yjp-controller-api-redist.jar {hostname} {port} capture-performance-snapshotTo capture memory snapshot$ java -jar {yourkit_profiler_directory}/lib/yjp-controller-api-redist.jar {hostname} {port} capture-memory-snapshot - To stop profiling, run:
$ java -jar {yourkit_profiler_directory}/lib/yjp-controller-api-redist.jar {hostname} {port} stop-cpu-profiling$ java -jar {yourkit_profiler_directory}/lib/yjp-controller-api-redist.jar {hostname} {port} stop-monitor-profilingIf memory profiling was turned on,s top it using the following command$ java -jar {yourkit_profiler_directory}/lib/yjp-controller-api-redist.jar {hostname} {port} stop-alloc-recording - Once you're done profiling, run the following so that on the next Go server restart, the agent is not loaded into the JVM.
In case of linux, run the following command:
$ sudo rm /usr/lib/yourkit/libyjpagent.so
In case of windows, delete the file C:\yjpagent.dll. If you were using the variable YOURKIT_PATH, then remove the environment variable.
Contact Go Support
If the Go server continues to behave poorly, send us the following data.
- Database file cruise.h2.db. Stop the server and take a backup of the database. Location:
Linux: /var/lib/db/h2db/cruise.h2.db
Windows: {go_installation_dir}\db\h2db\cruise.h2.db
- Log file go-server.log. Location:
Linux: /var/log/go-server/go-server.log
Windows: {go_installation_dir}\go-server.log
- Go config file cruise-config.xml. Location:
Linux: /etc/go/cruise-config.xml
Windows: {go_installation_dir}\config\cruise-config.xml
- If any Yourkit and jconsole snapshots as mentioned in the previous points, its useful if that can be sent too.