Cải thiện Performance và Scalability trong Drupal Site

Cải thiện Performance và Scalability trong Drupal Site

Here at Achieve Internet, we perform a lot of system reviews for our clients to help them improve the performance and scalability of their sites.  From these numerous system reviews, we've identified 5 common things that are missing from many hosting configurations.

  • APC
  • PHP realpath_cache_size
  • MySQL Query Cache
  • Memcached
  • Drupal optimizations


APC, or one of its alternatives, should be installed and configured on every web server. APC caches the compiled op-code for your PHP application. This has two main benefits:

  • Reduces the amount of time that it takes the server to render each page (pages load faster)
  • Reduces the amount of RAM that the server must use to render each page

There are two main APC settings that will have the greatest impact on your site:

  • shm_size
  • stat

The "shm_size" setting determines how much memory APC will allocate to caching your Drupal site's PHP code. A good starting point for a single Drupal 7 site is 64MB although you should monitor APC via the apc.php page to determine the optimal value for your server and sites.

The "stat" setting determines if APC checks the original PHP source files to see if they have been modified before using the cached version. By setting stat=0, you can tell APC that the source PHP files do not change and thus reduce the overhead of the disk I/O to check the status of the PHP files. A word of caution though for this setting: only disable stat on production servers where the source code rarely or never changes. Otherwise you'll find yourself having to manually clear the APC cache after every code update.

PHP realpath_cache_size

Drupal sites make extensive use of include files. By default PHP attempts to cache the file system pointers for any included file. However, the default cache size is too small for Drupal sites. Increasing this setting in your php.ini will reduce the number of disk I/O operations that PHP performs in rendering pages. A good starting point for this setting is 64KB although as with all optimizations, you should monitor the actual usage to determine the optimal value for your particular situation. You can see how much of the realpath cache is being used by creating a PHP page that calls ealpath_cache_size().

The impact of this setting will vary greatly from site to site.  On a large Drupal site you could see anywhere from a 1% to 10% improvement in page load times.

MySQL Query Cache size

The MySQL query cache caches the results of frequently run queries, though amazingly some default MySQL installations comes with this disabled. A good starting point for the query_cache_size is 128MB. The optimal value for this should be a value that provides a cache hit ratio of at least 95% while not having an excessive amount of unused memory.

A related setting is the query_cache_limit. This determines the largest query result set that can be stored in the cache. Generally, we start with the default value of 1MB and adjust up or down based on the information being cached.


Memcached is a memory resident data cache that is used to mostly replace the cache_* tables in the MySQL database. Installing Memcached and configuring your site to use it can have a dramatic impact on the performance and scalability of your site. On a stock Drupal installation, a test of Memcached showed that cache reads were 2x faster, cache writes 40x faster, and the number of database queries was reduced by almost 50% per page load.

Memcached can sometimes be challenging to setup and get working correctly since there are several pieces that have to be installed and configured to work together. The three main components you need to use Memcached are:

  • The memcached daemon itself (http://www.memcached.org)
  • The PHP PECL memcached extension (http://pecl.php.net/package/memcached)
  • The Drupal Memcache module (http://drupal.org/project/memcache)

Drupal optimizations

Drupal comes with some good performance optimization options out of the box when properly configured. Here are a few:

  • Enable Anonymous page caching.
  • Enable CSS, JS, and Page Aggregation/Compression.
  • Set the page cache expiration time reasonably large, say 60 minutes or more for sites with infrequently changing content.
  • Consider using the Boost module (http://drupal.org/project/boost) if your site is mostly anonymous traffic and you cannot setup a Varnish (https://www.varnish-cache.org/) server.

While most of the options out of the box work well, do not use the Statistics module.  Instead, use an external analytics service such as the Google Analytics API.


Achieving a high performance and scalability website is all about enabling your servers to render pages as quickly as possible while using as few resources as possible. These core tools are just the starting point for having a well tuned hosting environment and should be tailored for your specific situation and website.

A final word of caution, while we've provided some reasonable starting points for these optimizations, just blindly dropping them into your environment without tuning for your specific needs can actually reduce the performance of your site. Once these settings are tuned for your environment though, you will see a significant improvement in both performance and scalability.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Quảng cáo việc làm


Thích hợp các bạn nữ mảng thợ may làm việc tại nước NGA

Đơn hàng Tuyển dụng 100 Thợ may đi Nga(đợt 1 tháng 3.2021, đợt 2 tháng 5.2021). Lương thực lãnh 800 USD, bao ăn ở, vé máy bay và visa, phí xuất cảnh(1800 USD)trả khi đi làm có lương. Bạn có thể liên hệ CÔNG TY qua Phone/Zalo: (+84) 944 225 212. Công ty sẽ tư vấn cho bạn.

Xem chi tiết: >>> https://bit.ly/3o9NOfR

Tìm kiếm bất động sản





Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

Giới thiệu top 10 Drush commands tiếp theo

Giới thiệu top 10 Drush commands tiếp theo

Here is the top 10 Drush commands from the fine folk who contributed (in some cases, they are variations of a command that I listed in my post).


Mạng xã hội Renren - Khắc tinh của Facebook tại China

Việc chính phủ Trung Quốc ra tay chặn Facebook tất nhiên không thể cản nổi bước tiến của những cư dân mạng sinh hoạt trên mạng xã hội lớn nhất thế giới này. Mặc dù cộng đồng người sử dụng Facebook ở Trung Quốc có số lượng khá ít ỏi. Theo thống kê, hiện có khoảng 295.400 người ở Trung Quốc đang sử dụng Facebook. Điều này có nghĩa là cứ 10.000 người sử dụng internet ở Trung Quốc thì có 7 người có tài khoản Facebook đang sử dụng.

Seo top

Bảng giá SEO top 1 - 3 Google

Dịch vụ quang bá (SEO) website của chúng tôi bao gồm các bước sau: