We have 45 propietary GPS (NCP-300x ) for vehicles of a customer. They transmit between 35, 50MB per month per GPS using TCP to our server(in a VPS), and after 3 days the number of threads is aprox. 540. I keep restarting the server because i think that someting could be wrong. I clarify, it the problem is not with the memory but with the number of threads. After a restart the number is aprox. 53 but with hours this number increases, perhaps is insufficient cpu?
In my experience with a GPS simulator, if the CPU is low and the load is high(many packets) the number of threads increases, if the load is 0 the number of threads decrease. But in my real enviroment i can test it, please share your experiences.
These are my constants
public static final long TIMEOUT_TCP_IDLE = 0;
public static final long TIMEOUT_TCP_PACKET = 0;
public static final long TIMEOUT_TCP_SESSION = 0;
Thanks in advance,
The value 0 for TCP TIMEOUT is a wrong value to use.
0 means that the server never close the connection, so if the tracker for some reason lost the connection when reconnect will be used a new socket (and a new thread) but the previous socket is always opened.
This is the reason because you find about 540 thread on your DCS.
It's better to use a value different from 0 in your configuration, so after an idle period the server close the socket and free the port used.
There isn't a correct value to use, you must find the right value based on your application.
Higher values are suitable if your device send data with higher frequecy, a low value if the tracker sent data with low frequency.
If tha data transfer speed (GPRS connection) is low a little value of timeout could be drop the tracker transmission before ends.
I hope this can help you,