What do you mean Ruby on Rails is not thread safe?

I just read ROR (not yet dived into it) and I heard that it is not thread safe. Obviously, this does not mean that more than one person cannot access your site at a time, and what exactly does this mean? Where did the ROR come into play? Do they just mean query processing?

+6
multithreading ruby ruby-on-rails
source share
3 answers

Your information is out of date. It is thread safe with 2.2.2

Keep in mind Ruby MRI 1.8.x , the most widely used Ruby implementation uses Green Themes , so with 1.8.x, if you create 100 threads, they all run on the same processor. Therefore, when hosting Rails websites using MRI, you probably want all Ruby instances to work just like you have CPUS. Things like the passenger take care of this for you.

This was a big problem for JRuby because JRuby has its own threads, and juggling processes seem redundant. In any case, it was taken apart now.

Aside, Iron Ruby, the .Net Ruby interpreter runs its own threads.

Note. Ruby 1.9.1 uses native threads, but there is still a global interpreter lock.

+28
source share

Basically, this suggests that you cannot have multiple copies of rails running in the same process in different threads, because some of the resources can flow between threads that inadvertently cause strange behavior, such as objects disappearing into random time.

In addition, it may also be that classes are not designed with any kind of synchronization built into them, which makes it difficult to place parts of rails in streams and to separate other parts between streams.

+4
source share

It is worth noting that Ruby MRI 1.8.x uses Green Threads, but Ruby MRI 2 will have its own threads.

0
source share

All Articles