Parallel processing in Ruby

Parallel Processing can be achieved in two different ways, multi-core and single process threaded architecture. In a Multi core environment independent operations are shared between multiple CPU cores so as to obtain considerable improvements in performance. A single core threaded setup uses a single process with multiple threads for each individual operations using thread context switching for switching between the execution of different threads.  Threads are ideal where operations wait for longer times during I/O operations. When one Thread is blocked for I/O  a context switch takes place to another thread.  This results in collective improvement in performance.

A very simple example of using parallel processing(Threaded or Parallel Processes) is by the gem Parallel.

Note: Using Threads are dangerous and could result in actually slowing your execution if done wrongly be Warned.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s