Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have 100K of iot devices connecting on tcp server. I have to select specific services to be executed on each device based on the device id. Right now I am using a rest api, that I call upon when a device connects to the server,which in turn returns the list of services to be executed on the device, these services on each device are selected by users using a web portal, my problem is when all these devices connects at the same time, rest api server goes down or hangs or takes time to serve the request, my need is to get the response back in milliseconds please suggest any better solution that can server my purpose.

What I have tried:

Right Now I call a Rest API when a devices connects to the server that takes Device ID as an input parameter & returns the services list to be executed on the device.
Updated 13-Aug-20 10:33am
k5054 13-Aug-20 15:49pm    
Are you spawning a new thread or process when a device connects to the REST server? If you are not, look into how you might do that for your platform. If you are, then take a look at what you are doing between getting a connection and spawning the trhead/process.
Alternatively, look at spawning several processes when the REST server starts up, and put each one into listening mode. You probably want to keep the number of pre-spawned threads/processes below the number of CPU cores (or threads) you have available.
Dave Kreskowiak 13-Aug-20 18:07pm    
Hundreds of thousands of devices? Sound like you need to scale up your server to a farm of servers.
[no name] 13-Aug-20 21:04pm    
Instead of broadcasting, maybe you should be polling. Or start an inventory of services so you don't have to ask. etc. Not enough info in general.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900