Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is blocking and non-blocking web server, what difference between both?

Tags:

webserver

I have seen many a web framework provide a non-blocking web server, I just want to know what it means.

like image 594
vernomcrp Avatar asked Dec 18 '09 06:12

vernomcrp


People also ask

What is blocking vs non-blocking?

Blocking refers to operations that block further execution until that operation finishes while non-blocking refers to code that doesn't block execution.

What is the difference between blocking vs non blocking I O system calls?

Well blocking IO means that a given thread cannot do anything more until the IO is fully received (in the case of sockets this wait could be a long time). Non-blocking IO means an IO request is queued straight away and the function returns. The actual IO is then processed at some later point by the kernel.

What is blocking and non-blocking socket?

In blocking socket mode, a system call event halts the execution until an appropriate reply has been received. In non-blocking sockets, it continues to execute even if the system call has been invoked and deals with its reply appropriately later.

What is the difference between asynchronous and non-blocking?

Non-Blocking: It refers to the program that does not block the execution of further operations. Non-Blocking methods are executed asynchronously. Asynchronously means that the program may not necessarily execute line by line.


3 Answers

a blocking web-server is similar to a phone call. you need to wait on-line to get a response and continue; where as a non-blocking web-server is like a sms service. you sms your request,do your things and react when you receive an sms back!

like image 183
topgun_ivard Avatar answered Oct 01 '22 22:10

topgun_ivard


Using a blocking socket, execution will wait (ie. "block") until the full socket operation has taken place. So, you can process any results/responses in your code immediately after. These are also called synchronous sockets.

A non-blocking socket operation will allow execution to resume immediately and you can handle the server's response with a callback or event. These are called asynchronous sockets.

like image 36
ty. Avatar answered Oct 01 '22 23:10

ty.


Non-blocking generally means event driven, multiplexing all activity via an event driven system in a single thread, as opposed to using multiple threads.

like image 21
Yann Ramin Avatar answered Oct 01 '22 23:10

Yann Ramin