Finding ideal number of threads per process using GVL instrumentation
16-May-2025 15
In part 1 we saw how to find ideal number of processes for our Rails application.
In part 2, we learned about Amdahl's law which helps us find the ideal number of threads theoretically.
In this blog, we'll run a bunch of tests on our real production application to see what the actual number of threads should be for each process.
In part 1 we discussed the presence of GVL and the concept of thread switching. Based on the GVL's interaction, a thread can be in one of these three states.
Running: The thread has the GVL and is executing Ruby code.
Idle: The thread doesn't want the GVL because it is performing I/O operations.
Stalled: The thread wants the GVL and is waiting for it in the GVL wait queue.
Finding ideal number of threads per process using GVL instrumentation #ruby #rubydeveloper #rubyonrails #Finding #ideal #number #threads #process #using #instrumentation #threads https://rubyonrails.ba/link/finding-ideal-number-of-threads-per-process-using-gvl-instrumentation