Ruby and the Concurrency

Marat Saytakov
1 min readMay 17, 2016

--

I mastered the great article Ruby concurrency explained. I recommend this to everyone who are not an enterprise Ruby developer. These guys better know under the hood.

I am using Ruby on Rails for my homepage m4rr.ru. I am collecting there cities in the world where I have been. The USD-RUB Bot for Telegram is also running on that $5 droplet. And a bunch of other tools and services. But I not even reach Parse’s 3000 rps.

But it’s so good to know how things work. So here’s what I got.

Both Ruby and Python uses a Global Interpreter Lock.

This GIL is a locking mechanism that is meant to protect your data integrity. The GIL only allows data to be modified by one thread at time and therefore doesn’t let threads corrupt data but also it doesn’t allow them to truly run concurrently.

And it’s true. The common case to run code concurrently there is to use one or another run loop, or turn on another process.

This approach is unlike in my beloved iOS development. There we have GCD, operations and queues, threads, run loops, and dead locks.

--

--

No responses yet