Giới thiệu 3 cách nâng cao để boost Drupal performance

Giới thiệu 3 cách nâng cao để boost Drupal performance

Drupal is powerful CMS which used to built many high traffic websites. However, the performance of Drupal always a concern for many users. In my pervious article introduced 4 simple steps to boost Drupal performance for many anonymous visit. However, if your find those are not enoguht, there are 3 extra tricks which can further boost Drupal performance.

1. CacheRouter

CacheRouter is a module which can replace default Drupal caching mechanisms which allowing you to use individual cache tables for specific cache technology.

And CacheRouter fully support the following technologies:

  • APC
  • Database
  • eAccelerator
  • File
  • Memcache
  • XCache

To enable this, there are two simple steps:

i ) Enable the module in admin panel

Your should go to "http://yourdomain.com/admin/build/modules" to enable the CacheRouter module

ii) Configurate settings.php

First, you have to inform Drupal to use your common caching system by adding the follow line in setting.php.

     $conf['cache_inc'] = './sites/all/modules/contrib/cacherouter/cacherouter.inc';
     $conf['cacherouter'] = array(
           'default' => array(
           'engine' => 'db',
           'servers' => array(),
           'shared' => TRUE,
           'prefix' => '',
           'path' => 'sites/default/files/filecache',
           'static' => FALSE,
           'fast_cache' => TRUE,
         ),
     );

The above setting which tell Drupal to user CacheRouter to user for all cache bins and store the cache content as files. The cache    store in 'sites/default/files/filecache' directory.

Discuss about Drupal cache tables

There are several database tables that shipped with Drupal 6 for caching purpose:

  • cache - Used for all common cache purpose. This is a default cache bin for Drupal.
  • cache_block - Used for storing block's cache.
  • cache_filter - Used for storing filtered input.
  • cache_form - Used for stroing forms.
  • cache_menu - Used for storing assembled and processed menu.
  • cache_page - Used to store cached pages.
  • cache_update - Used to store Drupal, modules and themes update information if "Update status" enabled.

Other than default cache tables, there are some common cache tables used by those widely used modules:

  • CCK - cache_content - Used to store cck-related information.
  • Views - cache_views - Used to store view object and cache_views_data which storing query results and those rendered output.

Now, we have a brief understand how Drupal cache the data into which database tables. Here, we can do some extra cache configuration:

   $conf['cacherouter'] = array(

        'default' => array(

        'engine' => 'file',

        'servers' => array(),

        'shared' => TRUE,

        'prefix' => '',

        'path' => 'sites/default/files/filecache',

        'static' => FALSE,

        'fast_cache' => TRUE

   ),

   'cache_menu' => array(

        'engine' => 'db',

        'servers' => array(),

        'shared' => TRUE,

        'prefix' => '',

        'path' => '',

        'static' => FALSE,

        'fast_cache' => TRUE
    )
);

We can specify different cache bins use different kind of cahce mechanism. Like the code on above which specify "cache_menu" use db to cache.

2. Use Elysia Cron instead

Drupal's cron is an useful tool which can run heavy tasks in background through hook_cron. However, there are some limitations:

  • All cron job for all modules are run at the same time, in sequence, alphabetically or according to module weight.
  • If cron of one module get stuck, the rest of the modules would not be executed until cron run next time.
  • Limited information on which cron hook takes most time or which cron hook have problem get stuck.

By using Elysia Cron which allow you with great flexibility to manage your cron tasks, such as: reorder cron tasks, disable cron tasks. It also give you information on which cron task consumes most of the time. For more information, visit the module page here.

3. Use Memcache with Drupal

To further optimize, there is one more option is to use Memcahe.  It used RAM for storing data which is extremely fast. And we can configure cache bins to storu in memory. In order to do this, you should make sure your server installed with Memcached caching. Once your server installed, we can configurate Drupal use Memcache by adjusting configuration of CacheRouter.

   $conf['cacherouter'] = array(
       'default' => array(
       'engine' => 'memcache',
       'servers' => array('127.0.0.1:11211', '127.0.0.1:11212'),
       'shared' => TRUE,
       'prefix' => 'your_site_name_prefix',
       'path' => '',
       'static' => FALSE,
       'fast_cache' => TRUE
       )
   );

Here, we configurated Drupal to use memcached as backend with 2 instances ('127.0.0.1:11211', '127.0.0.1:11212'). And you can configurate the 2 instances located at two different IPs and ports, such as: '192.168.1.100:11211', '192.168.1.101:11212' . Prefix is used to separate different caches from each others. For instance - you may have several Drupal projects, which may use same  memcached instances.

In most cases, you need to configurate the size of bins and instances:

default:  For cache, cache_views, cache_update. 256 MBytes in size.

menu:    For cache_menu bin. 64 MBytes in size.

content: For cache_views_data, cache_content, cache_page bins. 64 MBytes in size.

block:     For cache_block bin. 64 MBytes in size.

filter:      For cache_filter bin. 64 MBytes in size.

form:      For cache_form bin. 64 MBytes in size.

Conclude

CacheRouter is a very useful module which allow Drupal to work with various kinds of cahching mechanism, such as: file base, db, memcache ... etc. However, compare CacheRouter with Boost module, it require more configuration and settings. However, it do provide more flexibility to optimize Drupal performance which is a very useful module to optimize performance for high traffic web site.

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

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

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

 
Chạy thử Google Android trên máy tính

Chạy thử Google Android trên máy tính

Bạn có muốn dùng thử phiên bản Android OS mới nhất của Google mà không phải mua điện thoại? Bài báo sau sẽ giúp bạn thực hiện mong muốn này với phiên bản mô phỏng Android SDK.

Hướng dẫn định dạng dữ liệu tốt hơn trong excel

Hướng dẫn định dạng dữ liệu tốt hơn trong excel

Một trong những việc mà người mới dùng Excel ngại nhất là định dạng dữ liệu, thường người dùng

Hướng dẫn tối ưu Drupal 8 Performance năm 2020

Hướng dẫn tối ưu Drupal 8 Performance năm 2020

I have really enjoyed how much easier it is to make Drupal 8 performant compared to its predecessors. When I first started working with Drupal 8 performance, I was surprised how few of the tips and tricks I used from Drupal 7