Vipin K

Vipin K

  • NA
  • 1
  • 614

Socket Server

May 18 2014 4:34 AM

Hi,

I need to write a High Performance TCP/IP server for receiving the data from the GPS devices and logging it to the database for display on Google Maps. There will be thousands of GPS devices connected to the GPS server and will be transmitting the data every 30 seconds and the display will be set to refresh typically every minute. I am looking for the help in specific areas, I will write the code myself and believe me I will post the complete developed and tested code on this same forum. I understand the following challenges

1. Concurrent TCP/IP connections

2. Database table bottlenecks

I would like to go for one table per device groups and different ports for devices with different protocols. I am assuming that I will need to write the following components.

1. Data Receiver

2. Parser as per the protocol and the commands

3. Data Cache

4. Database writer

Receive the bytes, log the received commands to the cache, implement the lazy writer to flush the data every minute to the database using different thread. Please comments on the following.

1. Does the GPS device disconnects after sending one command or it keep the connection to send the data further like long polling?

2. Is it better idea to maintain the thread pool and keep one thread per device? How many devices can be connected simultaneously to one port?

3. If I assume that device does not disconnect the client after transmitting the bytes to the server, should I keep the channel alive on the server to keep on reading the data every 20 seconds or whenever available?

4. Is it fair enough to have the separate threads for updating the data to the database server? Say data retrieval every 20 seconds and making it persistent to the database every one minute?

5. Is there any other better protocol rather that raw TCP/IP? I guess the other protocols like http etc should be slower as the header size itself is very big.

6. What is better choice Synchronous or Asynchronous sockets? Is it feasible to use UDP?

7. What is better choice? C# and SQL Server or JAVA and mySQL on Linux?

Many Thanks

Vipin