Thursday, February 23, 2012
 

High performance photo gallery

So like everyone nows or not :D i own two gallerys:

  • http://animeonly.org [70 000 images]
  • Adult dedicated gallery. I will not paste link, except receive demand :) ~[150 000] images.

So this time decided to share some architecture decisions and of course share source code.

It's very interesting making these types of projects, especially then someone uses it. So what technology was used:

  • PHP 5.3.1
  • Lighttpd
  • Memcached
  • Etag based caching
  • APC
  • Sphinx

This combination of software within cached pages gives render time in about 0.005 second. see http://animeonly.org if you do not believe me.

Sphinx

Sphinx was used just for string search. It's much better than myself full text search. It's not the only project i used Sphinx search engine. Gallery currently is using newest and requires 0.9.9.x sphinx version. I really liked new way of implementing OR condition in new sphinx version. Currently you can supply SQL syntax quaries like:

$cl->SetSelect ( "*, userid=123 OR groupid=456 AS mycond" );
$cl->SetFilter ( "mycond", array(1) );// FAQ section i think contains a bug
$cl->Query ( "my query", "myindex" );

Memcached

Currently memcached is used for objects caching and page caching.

ETag caching

Etag caching is used in albums and categories. It's very efficient way of saving server bandwidth.

Perfomance benchmarks

Server software

  • Lighttpd
  • APC
  • 2GB ram
  • processor       : 0
    vendor_id       : GenuineIntel
    cpu family      : 6
    model           : 23
    model name      : Pentium(R) Dual-Core  CPU      E6500  @ 2.93GHz
    stepping        : 10
    cpu MHz         : 2933.543
    cache size      : 2048 KB
    • It's single CPU
       
  • Mysql 5.1
  • Benchmark was done under normal server working condition.

Benchmark of last uploads page. Totaly cached page.

[root@remdex devhppg]# ab -c 100 -n 500 http://animeonly.org/gallery/lastuploads/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking animeonly.org (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests


Server Software:        lighttpd/1.4.22
Server Hostname:        animeonly.org
Server Port:            80

Document Path:          /gallery/lastuploads/
Document Length:        26391 bytes

Concurrency Level:      100
Time taken for tests:   2.914846 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      13363046 bytes
HTML transferred:       13195500 bytes
Requests per second:    171.54 [#/sec] (mean)
Time per request:       582.969 [ms] (mean)
Time per request:       5.830 [ms] (mean, across all concurrent requests)
Transfer rate:          4476.74 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.3      0       5
Processing:   159  532 278.3    471    1856
Waiting:      157  532 278.2    471    1855
Total:        160  533 278.2    471    1856

Percentage of the requests served within a certain time (ms)
  50%    471
  66%    554
  75%    584
  80%    608
  90%    668
  95%   1364
  98%   1751
  99%   1793
 100%   1856 (longest request)

Source code

Early verson of source code can be found. It's not fo production use, because a lot of part need to change to be configurable, need install and so on. But tu get picture of software it quet usefull. I'm planning during one month preprate install for gallery and fix remaining hardcoded things.

http://redmine.remdex.info

 

Back »

Comments: 0

Leave a reply »

 
  • Leave a Reply
    Your gravatar
    Your Name
     
     
     
     
 
About Remdex site

Simple site for simple peoples.

Get in touch

E-mail: remdex@gmail.com