Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between thread-isolated and semaphore-isolated calls

I was going through the Netflix opensource feature Hystrix... I saw a statement "Today tens of billions of thread-isolated, and hundreds of billions of semaphore-isolated calls are executed via Hystrix every day at Netflix"

Would like to know the difference between these different type of calls..

like image 287
shiv455 Avatar asked Jan 29 '16 04:01

shiv455


1 Answers

First we need to see the different between thread and semaphore. In general, calling thread is more expensive than semaphore because of the overhead. So for a large number of requests/second, then semaphore will be something you can considere.

Secondly with semaphore, the command will be executed within the thread of the caller. It means that the concurrent calls are not fully isolated from other (not like when you use thread).

Lastly, with semaphore, when there is a timeout, it can't be terminated (unless you specifically set it up). If you don't know what will be the client's behaviour ,then this would be not a nice thing to have.

like image 194
Xitrum Avatar answered Oct 28 '22 02:10

Xitrum