gcc 4.4.1
I am writing a server program where many clients will connect to the client and the server will manage the clients request and manage the state of the client. Many clients under high load would be a deciding factor in using Asynchronous programming. However, I have never done Async in C.
However, from what I understand from my research I think I need to use Async.
1) Using Synchronous programming would mean that calls would be blocked and would create a bottle neck. The system would just crash under high load
2) Using Synchronous programming using threads would create a new thread for each client, which would mean under high load the system resources could be used up and could make the system over complex handling all those threads.
3) Using Async would mean I would have to develop a state machine???
Can anyone point me in the right direction? In programming in Aysnc?
Many thanks for any advice,
put the incoming requests into a queue
use one thread to dispatch the queue
requests taken from the queue are executed in their own thread; the queue can throttle the number of active threads (the thread pool) to prevent overloading the server. Requests won't be lost, but they may sit in the queue for a little while awaiting processing.
the queue manager can also kill threads that are taking too long, if you like
good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With