Please note that the memcache-client provided by rails2.3 has performance problems.

Source: Internet
Author: User

Rails2.3 has been released. The internal version of rails2.3 has been greatly changed. For more information, see javaeye.

Because I trust the rails framework too much and have not conducted a local performance test, I am eager to launch it after passing the compatibility test. This launch immediately blocked a large number of dynamic requests and carefully looked at the crash of FastCGI.
Log, and Broen occurs when a large number of requests are flushed data.
Pipe. Open rails2.3's new rack frameworkSource codeThe FastCGI adapter looks at thisCodeThe write is too irresponsible! The FastCGI protocol itself does not set a buffer, and the written data is immediately sent out. As a result, rack is redundant and flushed after each data write, causing the connection to be closed, fastCGI is still waiting for flush data!

Modified the FastCGI of rack.
Adapter, local pressure test, FastCGI no longer reports errors, code is released online, and immediately blocked, load is very high, this began to suspect that rack FastCGI support is not good, resulting in poor performance?
Because thin is the best rails application server to support rack, we changed the rails running mode of the website from FastCGI to thin, and released the code again, blocking it again, and blocking it more seriously, load is much higher than FastCGI!
It can also be seen that FastCGI is still the best running method in rails performance after all.

The FastCGI problem was completely ruled out, and several other places that may affect the performance were investigated. The problem that rails2.3 was blocked when the request was launched. Finally, I honestly conducted a local performance test, and now the truth is revealed. In my local MacOSX environment, rails2.2 can process 40 requests per second, but rails2.3 can only process 25 requests per second, while the CPU consumption is more and the process memory usage is higher!

The final reason is that the memcache-client of rails2.3 has a major performance problem.

To put it simply, rails2.2's built-in memcache-client is version 1.5.0. This is a stable version that has been in use for a long time.
Memcache-client is officially released. rails2.3's memcache-client is upgraded to version 1.6.5, which is a brand new version. It is only available on GitHub and has not been officially released, it can be seen as a development version, which has numerous problems!

First, it sets a weird timeout parameter. By default, it causes connection to memcache
Server speed becomes abnormal and slow. After the timeout parameter is changed to nil, the speed returns to normal.

Second, it connects to memcache
Every method operation of the server is changed to a closure call. Although code and Exception Handling seem more elegant, performance tests show that the overall application performance will decline a lot.

Third, there are some self-contradictions in the Code, for example, multi-thread detection and processing code errors.

In short
After the Client Version is changed to the old version 1.5.0, the performance problem is solved. The local performance test results show that the javaeye code is run on rails2.3, the speed is 11% faster than rails2.2, but the memory consumption has increased (estimated as the local speed of rails2.3 ).
Cache ).

Of course, memcache-client 1.6.5 is not useless. It adds the ability of automatic failover (in multiple memcached
Server), internal code is also restructured (although the reconstruction result is lower performance), and some multi-threaded support is added (although this part of the Code cannot work at all ), after all, this is an immature version in development. rails should not be rashly upgraded to memcache.
Client Version.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.