Optimization

This document provides information for configuring Traccar and operating system to work with large number of devices and users.

Increasing connection limit on Linux

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":

root soft  nofile 50000
root 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.

Setting connection timeout in Traccar

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.

Selecting database engine

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).