Question

We're scratching our heads the last couple of days trying to understand why some things seem a bit too slow with redis/ohm on our rails project.

The gist of it is that some requests to ohm/redis take around 100-200 ms, which seem rather high considering our high-expectations of blazing-fast performance.

The command we're running looks like:

Stats::TermStats.find(term_slug: 'term_slug', user_id: 123).to_a

It seems to us that we're not doing anything extremely complex or crazy. Our profiling (using miniprofiler) of this single command so far revealed the following:

  • Some of those calls complete within about 2-4 ms (is this ok/good/bad?)
  • Some however take 100-200 ms (this definitely feels bad)
  • Using slowlog get on the redis-client does not show anything particularly slow on redis. Most of the redis command complete within less than 20 microseconds (0.02 ms)
  • Using the rails console and running a quick benchmark using the exact same slug/id in a loop, the same behaviour is observed, i.e. a few of those (same) requests seem to take considerably longer than most others

Our redis config is pretty much out-of-the-box with basically no tweaking. During testing the server is not doing much else.

Any suggestions how to improve performance / test what slows down things so much between redis and ohm/rails ??

Était-ce utile?

La solution

In case anybody's interested, we seemed to have found the cause for this problem, and even a solution

TL;DR : use hiredis + tune the ruby GC parameters.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top