A
A
Alexander Movchan2015-07-16 15:13:31
Programming
Alexander Movchan, 2015-07-16 15:13:31

How to efficiently use server resources?

I decided to practice writing client-server applications. On the server we have something like this:

while True:
            server.acceptNewClients()
            server.handleQueries()

However, it turns out that such a server unnecessarily loads the system even without a single client. At startup, the coolers immediately accelerate. Added a delay to the loop:
while True:
            server.acceptNewClients()
            server.handleQueries()
            time.sleep(0.1)

Now there is no unnecessary load, but such a server will be inefficient with a large number of clients.
Is there any universal solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
asd111, 2015-07-16
@Alexander1705

you need to use the operating system messaging mechanism i.e. e.g. epool, kqueue etc. - implemented in libevent, libev libraries
In such cases, processing occurs only after receiving data, and while there is no data, the system waits

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question