Question

We are developing a TCp Server of 1k connections, with async calls it is working fine. But we have to save the data of each client in DB separately.

How to manage this much large pool of DB connections ideally what should be hardware required? Can we use a single core machine for TCP Server 1k connection?

INFO: We are having GPRS enabled tcp clients(These are hardware devices which connect to tcp server every 1 min and sends data. Current Db MYSQL

Was it helpful?

Solution

I would implement it as follows:

  1. Have a collection of data that is waiting to be saved protected by a lock.

  2. When a thread has new data to be saved, acquire the lock on the collection, add the data to the collection, and release the lock.

  3. Have a "save thread" (or save job, or whatever is appropriate for your language or threading library) that periodically acquires the lock on the collection, swaps the collection for an empty collection, releases the lock, and then saves all the data in the collection in a single SQL transaction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top