This document provides information for configuring Traccar and operating system to work with large number of devices and users.
You can check hard and soft limits for current user using following commands:
ulimit -Hn ulimit -Sn
By default Traccar runs from root user account as a daemon (service), so you have to check limits for root user. On most systems by default the limit is around 1024 connections.
To increase the limit add following lines to "/etc/security/limits.conf":
* soft nofile 50000 * hard nofile 50000
Make sure you use number higher than your number of devices because when device reconnects it might consume two or even more connection for some period of time.
After following instructions above you might find that connection limit doesn't increase past 65k or some other number. This is because of the vm.max_map_count variable.
To fix the issue you need to modify "/etc/sysctl.conf":
vm.max_map_count = 250000 fs.file-max = 250000 net.ipv4.ip_local_port_range = 1024 65535
First two parameters allow to increase total limit of connections to 250k. Last parameter is important to increase local port range, which would allow more connections on a single port. By default range is usually around 32k.
Don't forget to restart the system after modifying the file.
Operating system has timeout for all TCP connections, but it's usually very high. For example, on Linux it's common to have 2 hours timeout. It means that if your device re-connects without gracefully closing connection, then it will leave a hanging connection on the server that consumes server resources and is counted against total connection limit. When network connection is poor, a single device can easily create tens or even hundreds of connections within 2 hour period.
To avoid the problem, it's recommended to set connection limit in Traccar server. You can use "timeout" option in the config file. It's configured per protocol, and it's recommended to set the value (in seconds) to slightly higher than your device reporting interval.
Traccar uses Java virtual machine, so it has restrictions on the amount of memory it can use on the system. YAJSW (service wrapper) allows to configure memory limits. You need to add following line to the "/opt/traccar/conf/wrapper.conf" config file:
Above example sets limit to 2GB. You need to pick appropriate value for amount of available memory on the system.
You can find other available configuration parameters on the official YAJSW config page.
Starting with version 4.1, YAJSW is no longer used, so you change the java heap size by adding following to the start script:
On Linux the start script can be typically found at /etc/systemd/system/traccar.service:
ExecStart=/opt/traccar/jre/bin/java -Xmx1G -jar tracker-server.jar conf/traccar.xml
In above example the maximum heap size is set to 1GB.
By default Traccar uses embedded H2 database system. It's used to simplify initial set up and configuration of the server software, but for any production environment it's strongly recommended to use a fully-featured database engine. One of the best results in terms of performance are observed with MySQL database. Traccar also supports other popular database systems (Microsoft SQL Server, PostgreSQL, Oracle and others).
Make sure that database is configured appropriately to amount of data and traffic you plan to manage. By default cache size and other configuration parameters might not be appropriate.