Monday Oct 26, 2009

memsession 1.0.1 stable is now available

Install it from pecl using :
$ pecl install memsession

Caching file_get_contents output inside APC.


APC creates a mmap which is used for caching compiled php response. Besides this APC provides API to cache user data into this mmap. There are many php apps which uses file_get_contents to read the static files. If APC can cache these files in it's mmap, it will improve file_get_contents performance.

Based on the above idea, I developed a patch which stores the file_get_content output in APC's cache. In this patch, APC intercepts the calls of file_get_contents and replaces it with apc_file_get_contents function. If file is a full path and entire file is requested then APC caches the content.

To enable the caching use the following in php.ini :
apc.cache_static_contents=1
apc.user_ttl = 30

apc.user_ttl will decide how long the entry will remain inside the cache.  If apc.user_ttl is set to 0 then the entry will never be removed from cache.

Here is the performance data collected using Studio 12 on Solaris sparc for ecommerce php benchmark. (3500 simultaneous users)
Run
Excl. User CPU  sec.
Incl. User CPU sec.
Excl. Total LWP  sec.
Incl. Total LWP  sec.
Excl. Sys. CPU sec.
Incl. Sys. CPU sec.
Name
Without  Cache
0.831
28.660
1.141
540.018
0.030
344.311
zif_file_get_contents
With Cache
1.481
181.537
1.821
282.758
0.140
12.449
zif_apc_file_get_contents

User + System time before Caching = 372 seconds
User + System time after Caching = 193 seconds
Total time reduction in file_cache_contents = 48%

When static file is inside the cache then server will not do any stat calls. Which means if file changes then cache will still serve the old cached file during apc.user_ttl interval.

Monday Oct 05, 2009

memsession 1.0.0 beta is now available

Memsession 1.0.0 beta is now available, you can install it using pecl.
$ pecl install memsession-beta

About

Basant Kukreja

Search

Top Tags
Archives
« October 2009 »
SunMonTueWedThuFriSat
    
1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
27
28
29
30
31
       
Today