SlideShare uma empresa Scribd logo
1 de 32
Introducing high performance
photo gallery
● Remigijus Kiminas
2010-11-29
v5
Who I am?
● Author of
– http://livehelperchat.com/
– http://redmine.remdex.info my projects :)
● Currently working
http://www.coralsolutions.com/
– Freelancing and building open-source
software in free time
Purpose of the presentation 1
● Present some architecture decisions witch
were applied building image gallery
What's new since last presentation
● Mobile devices get support
● Image gallery can be used as shopping CMS
– Credit's based buying
– Checkout using paypal service
● Uncached pages get speed improvement by
finding bug in paginator.
● Official ngnix support
What's new since last presentation 2
● Extensions
● Kernel modules override
● Kernel classes override
● CSS compile
● Most popular images in 24 hours
● Photo approvement functionality
● Image filtering by resolution
What's new since last presentation 3
● Thumbnails recreation script
● 100% duplicates management accuracy
● More configurable system aspects as:
– Max upload photo size
– Max archive size
– Max file queue size
● Animated gif support
What's new since last presentation 4
● Animated gif support
● Completely fixed AJAX navigation usability, no
more confusing of available images to left or to
right.
● Front end design remake, thanks to
http://pauliusc.lt
● HTML output compression
● HTML 5 frontend changes, saves bandwidth
●
What's new since last presentation 5
● Some performance improvement regarding users
permissions settings
● More things moved to Memcached service
What's new since last presentation 5
V4
● Sort by relevance was introduced
● AddQuery usage implementation in search
● Refactored search page. One query less now.
● Paginator updates
● Sphinx wildcard support
● Images without original deletion script
● SEO enchancement related to resolution and user
current page
What's new since last presentation 5
V5
● Refactored captcha, it's now AJAX/javacript
based, performs well, plus saves one request on
image preview window
● Image preview full window cache!!! cached
windows is as fast as cached pagination around
5ms
● Image counter from log file, avoid insert on each
image preview window
What's new since last presentation 5
V5
● Mysql query hint for album pagination, mysql
planner choosed wrong indexes
● Smart selects in image preview window
● Full multilanguage support including translatable
module URL!!! none of my known gallery/cms
has this featyre. E.x gallery/search (engish) or
gallerie/recherche (french)
● Full InnoDB support. Performs well as MyISAM.
Top process is PHP not Mysql :)
Future works
● Pagination sharding with index filter shard table.
It should boost large sets of pagination around
100% > and keep constant speed with millions
of photos.
● http://remdex.info/Optimising-mysql-limit-performan
● Backend redesign
Issues with previous image gallery's I had
● A lot of users = a lot of problems
– No caching support
– Unoptimized SQL query's
– Resource hungry
– No framework used (well, perhaps this is not a problem, but most of the time
they just duplicate frameworks functionality, reinventing the wheel...)
– No Etag based caching, bandwidth saver...
Requirements
● Optimized SQL queries
● Fulltext search engine
● Etag based caching
● SQL querys caching
● Fullpage caching
● Low resource requirements
Adopted software
● APC – opcode cache for PHP
● Sphinx – free open-source SQL full-text search engine (http://sphinxsearch.com/)
● Memcached – free & open source, high-performance, distributed memory object caching
system
(http://memcached.org/)
● eZ Components – an enterprise-ready, general-purpose PHP library of components used
independently or together for PHP application development.
(http://ez.no/ezcomponents)
● JQuery – is a fast and concise JavaScript Library that simplifies HTML document
traversing, event handling, animating, and Ajax interactions for rapid web development.
(http://jquery.com/)
● Lighttpd – lightweight open-source web server.
(http://www.lighttpd.net/)
● Mysql – database engine
(http://www.mysql.com)
Adopted software
● Ngnix - A HTTP and mail proxy server licensed
under a 2-clause BSD-like license.
(http://nginx.org/)
● Fully working ngnix config provided. For eshop
requirements and standard
Building process – core
● Gallery core is based on eZ Components. Used
components:
– Authentication
– Configuration
– Database
– Feed
– ImageAnalysis
– ImageConversion
– PersistentObject
– Translation
– Cache
– Url
– UserInput
Fulltext search implementation
● Why sphinx?
– Very very fast :)
● Used features of 9.9
– SetSelect – this feature was introduced in 9.9
version and allowed to make fancy filtering.
– Example in next slide
Image full mode problem with
previous and next image
● Search condition in literal. I need to find 2 previous
images based on current image position including
search keyword, sorting mode.
●
● URL consists of
– Current image ID (16679)
– Keyword (haposai)
– Sort mode (popular)
● How do I find out what should I display in two first thumbnails (middle image is current our image)?
●
Solution
● Use SetSelect query
$cl->SetSelect ( "*, (hits > '.$Image->hits.' OR (hits = '.$Image->hits.' AND pid > '.$Image-
>pid.')) AS myfilter" );
$cl->SetFilter ( "myfilter", array(1) );
● Things I do not know how to do till now. If sorting is based on relevance
how to now previous two images.
● I know now. But:
– SetSelect does not work with @weight attributes in it.
– Had to use two query's. SetFilter() works with @weight
– AddQuery comes in help here for perfromance. Mutch more
relevance images now.
Some search statistic
● Each day around 190 K querys. It were more if
search result page were not be cached :)
●
Mysql performance tweaking
● Just optimise querys (EXPLAIN is you friend)
● Not a single slow query
● Some tips:
– With large data sets use
– SELECT * FROM `lh_gallery_images`
– INNER JOIN ( SELECT pid FROM lh_gallery_images ORDER BY comtime DESC, pid DESC LIMIT 20 OFFSET 20
) AS items
– ON lh_gallery_images.pid = items.pid
– This query is at least 5x times faster than normal select.
Tested with (150 K records.)
– See - http://www.mysqlperformanceblog.com
Supported HTTP servers
● Lighttpd
● Apache
● Ngnix
– With ngnix managed to produce around 1200 Q/S
on cached page. It's 30% more than with
Lighttpd.
Caching objects
● Version caching
– http://www.bestechvideos.com/2009/03/21/railslab-scaling-rails-episode-8-memcached
– http://www.infoq.com/presentations/lutke-rockstar-memcaching
– Version cache were used in
● Album pages
● Last uploaded
● Last hits
● Popular images and so on.
● The most popular images in 24 hours
– Then cache is cleared?
● It's not, only version number is increased, and automatic cache self expire, because cache key does not
exists.
–
Some code with version cache
● Cache Key calculation in Album
● $cache = CSCacheAPC::getMem();
$cacheKey = md5('version_'.$cache->getCacheVersion('album_'.(int)$Params['user_parameters']['album_id']).
$mode.'album_view_url'.(int)$Params['user_parameters']['album_id'].'_page_'.$Params['user_parameters_unordered']['page']);
– Includes:
● Album version
● $mode – sorting mode (Ex. Popular)
● Page
this combination gives unique cache version for each page.
● Same logic applies to all listing pages
Some benchmarks[root@ks310613 ~]# ab -n 500 -c 10 http://animeonly.org/Fantasy/Mix-16a.html
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
Server Hostname: animeonly.org
Server Port: 80
Document Path: /Fantasy/Mix-16a.html
Document Length: 26883 bytes
Concurrency Level: 10
Time taken for tests: 0.545137 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 13593092 bytes
HTML transferred: 13441500 bytes
Requests per second: 917.20 [#/sec] (mean)
Time per request: 10.903 [ms] (mean)
Time per request: 1.090 [ms] (mean, across all concurrent requests)
Transfer rate: 24349.84 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 5 10 2.9 9 23
Waiting: 4 9 3.1 9 23
Total: 5 10 2.9 9 23
Percentage of the requests served within a certain time (ms)
50% 9
66% 12
75% 13
80% 13
90% 13
95% 13
98% 20
Etag base caching
● What is it?
– An ETag (entity tag) is part of HTTP, the protocol
for the World Wide Web. It is a response header
that may be returned by an HTTP/1.1 compliant
web server and is used to determine change in
content at a given URL
(http://en.wikipedia.org/wiki/HTTP_ETag)
How to use it?
$ExpireTime = 3600;
$currentKeyEtag = md5($cacheKey.'user_id_'.erLhcoreClassUser::instance()->getUserID());;
header('Cache-Control: max-age=' . $ExpireTime); // must-revalidate
header('Expires: '.gmdate('D, d M Y H:i:s', time()+$ExpireTime).' GMT');
header('ETag: ' . $currentKeyEtag);
$iftag = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] ==
$currentKeyEtag : null;
if ($iftag === true)
{
header ("HTTP/1.0 304 Not Modified");
header ('Content-Length: 0');
exit;
}
● $cacheKey – from previous example cache key
● User ID is needed if user is logged in.
● Can be used for custom pages, that do not change
● Then image is uploaded or deleted, we just increase cache version and Etag is expired automatic
also.
●
Some MRTG screen shots 1
● Hits per hour
●
●
● Mysql queries
●
Some MRTG screen shots 2
● Memcached status
●
●
● Traffic stats
●
Conclusions
● Single server with sphinx, memcached, mysql,
nginx handles per day around 180 K pageviews
daily.
● No performance issues at this time.
● Gallery home page
http://code.google.com/p/hppg/
Thank you for your attention :)
● Questions etc:
– remdex@gmail.com

Mais conteúdo relacionado

Mais procurados

Drupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case StudyDrupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case Studyhernanibf
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Wim Godden
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Wim Godden
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 
Front end performance optimization
Front end performance optimizationFront end performance optimization
Front end performance optimizationStevie T
 
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...Anusha Chickermane
 
Memcached Presentation @757rb
Memcached Presentation @757rbMemcached Presentation @757rb
Memcached Presentation @757rbKen Collins
 
Nginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP TricksNginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP TricksAdam Wiggins
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?Remy Sharp
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalabilityTwinbit
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHPJonathan Klein
 
PyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slidesPyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slidesArtur Barseghyan
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Djangoscottcrespo
 
WordPress Need For Speed
WordPress Need For SpeedWordPress Need For Speed
WordPress Need For Speedpdeschen
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIBrian Hogg
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAEWinston Chen
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareOpevel
 

Mais procurados (20)

Drupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case StudyDrupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case Study
 
Front End Performance
Front End PerformanceFront End Performance
Front End Performance
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Front end performance optimization
Front end performance optimizationFront end performance optimization
Front end performance optimization
 
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
 
Memcached Presentation @757rb
Memcached Presentation @757rbMemcached Presentation @757rb
Memcached Presentation @757rb
 
Nginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP TricksNginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP Tricks
 
Php go vrooom!
Php go vrooom!Php go vrooom!
Php go vrooom!
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
 
PyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slidesPyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slides
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Django
 
WordPress Need For Speed
WordPress Need For SpeedWordPress Need For Speed
WordPress Need For Speed
 
Php on Windows
Php on WindowsPhp on Windows
Php on Windows
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAE
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshare
 

Semelhante a HPPG - high performance photo gallery

Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend PerformanceThomas Weinert
 
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling StoryPHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Storyvanphp
 
WordPress performance tuning
WordPress performance tuningWordPress performance tuning
WordPress performance tuningVladimír Smitka
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGearsAlessandro Molina
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on SteroidsSiteGround.com
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magentoMathew Beane
 
High performance website
High performance websiteHigh performance website
High performance websiteChamnap Chhorn
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performanceAndrew Siemer
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Per Henrik Lausten
 
Realtime traffic analyser
Realtime traffic analyserRealtime traffic analyser
Realtime traffic analyserAlex Moskvin
 
Journey through high performance django application
Journey through high performance django applicationJourney through high performance django application
Journey through high performance django applicationbangaloredjangousergroup
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
 
Barcelona mysqlnd qc
Barcelona mysqlnd qcBarcelona mysqlnd qc
Barcelona mysqlnd qcAnis Berejeb
 
Mysqlnd Query Cache
Mysqlnd Query CacheMysqlnd Query Cache
Mysqlnd Query CacheAnis Berejeb
 
Web performance optimization - MercadoLibre
Web performance optimization - MercadoLibreWeb performance optimization - MercadoLibre
Web performance optimization - MercadoLibrePablo Moretti
 
5 things you didn't know nginx could do
5 things you didn't know nginx could do5 things you didn't know nginx could do
5 things you didn't know nginx could dosarahnovotny
 
ASP.NET Scalability - VBUG London
ASP.NET Scalability - VBUG LondonASP.NET Scalability - VBUG London
ASP.NET Scalability - VBUG LondonPhil Pursglove
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceArjan
 

Semelhante a HPPG - high performance photo gallery (20)

Varnish - PLNOG 4
Varnish - PLNOG 4Varnish - PLNOG 4
Varnish - PLNOG 4
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling StoryPHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
 
WordPress performance tuning
WordPress performance tuningWordPress performance tuning
WordPress performance tuning
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGears
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
 
High performance website
High performance websiteHigh performance website
High performance website
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performance
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
 
Realtime traffic analyser
Realtime traffic analyserRealtime traffic analyser
Realtime traffic analyser
 
Journey through high performance django application
Journey through high performance django applicationJourney through high performance django application
Journey through high performance django application
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
Barcelona mysqlnd qc
Barcelona mysqlnd qcBarcelona mysqlnd qc
Barcelona mysqlnd qc
 
Mysqlnd Query Cache
Mysqlnd Query CacheMysqlnd Query Cache
Mysqlnd Query Cache
 
Web performance optimization - MercadoLibre
Web performance optimization - MercadoLibreWeb performance optimization - MercadoLibre
Web performance optimization - MercadoLibre
 
Performance (browser)
Performance (browser)Performance (browser)
Performance (browser)
 
5 things you didn't know nginx could do
5 things you didn't know nginx could do5 things you didn't know nginx could do
5 things you didn't know nginx could do
 
ASP.NET Scalability - VBUG London
ASP.NET Scalability - VBUG LondonASP.NET Scalability - VBUG London
ASP.NET Scalability - VBUG London
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 

Último

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Último (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

HPPG - high performance photo gallery

  • 1. Introducing high performance photo gallery ● Remigijus Kiminas 2010-11-29 v5
  • 2. Who I am? ● Author of – http://livehelperchat.com/ – http://redmine.remdex.info my projects :) ● Currently working http://www.coralsolutions.com/ – Freelancing and building open-source software in free time
  • 3. Purpose of the presentation 1 ● Present some architecture decisions witch were applied building image gallery
  • 4. What's new since last presentation ● Mobile devices get support ● Image gallery can be used as shopping CMS – Credit's based buying – Checkout using paypal service ● Uncached pages get speed improvement by finding bug in paginator. ● Official ngnix support
  • 5. What's new since last presentation 2 ● Extensions ● Kernel modules override ● Kernel classes override ● CSS compile ● Most popular images in 24 hours ● Photo approvement functionality ● Image filtering by resolution
  • 6. What's new since last presentation 3 ● Thumbnails recreation script ● 100% duplicates management accuracy ● More configurable system aspects as: – Max upload photo size – Max archive size – Max file queue size ● Animated gif support
  • 7. What's new since last presentation 4 ● Animated gif support ● Completely fixed AJAX navigation usability, no more confusing of available images to left or to right. ● Front end design remake, thanks to http://pauliusc.lt ● HTML output compression ● HTML 5 frontend changes, saves bandwidth ●
  • 8. What's new since last presentation 5 ● Some performance improvement regarding users permissions settings ● More things moved to Memcached service
  • 9. What's new since last presentation 5 V4 ● Sort by relevance was introduced ● AddQuery usage implementation in search ● Refactored search page. One query less now. ● Paginator updates ● Sphinx wildcard support ● Images without original deletion script ● SEO enchancement related to resolution and user current page
  • 10. What's new since last presentation 5 V5 ● Refactored captcha, it's now AJAX/javacript based, performs well, plus saves one request on image preview window ● Image preview full window cache!!! cached windows is as fast as cached pagination around 5ms ● Image counter from log file, avoid insert on each image preview window
  • 11. What's new since last presentation 5 V5 ● Mysql query hint for album pagination, mysql planner choosed wrong indexes ● Smart selects in image preview window ● Full multilanguage support including translatable module URL!!! none of my known gallery/cms has this featyre. E.x gallery/search (engish) or gallerie/recherche (french) ● Full InnoDB support. Performs well as MyISAM. Top process is PHP not Mysql :)
  • 12. Future works ● Pagination sharding with index filter shard table. It should boost large sets of pagination around 100% > and keep constant speed with millions of photos. ● http://remdex.info/Optimising-mysql-limit-performan ● Backend redesign
  • 13. Issues with previous image gallery's I had ● A lot of users = a lot of problems – No caching support – Unoptimized SQL query's – Resource hungry – No framework used (well, perhaps this is not a problem, but most of the time they just duplicate frameworks functionality, reinventing the wheel...) – No Etag based caching, bandwidth saver...
  • 14. Requirements ● Optimized SQL queries ● Fulltext search engine ● Etag based caching ● SQL querys caching ● Fullpage caching ● Low resource requirements
  • 15. Adopted software ● APC – opcode cache for PHP ● Sphinx – free open-source SQL full-text search engine (http://sphinxsearch.com/) ● Memcached – free & open source, high-performance, distributed memory object caching system (http://memcached.org/) ● eZ Components – an enterprise-ready, general-purpose PHP library of components used independently or together for PHP application development. (http://ez.no/ezcomponents) ● JQuery – is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. (http://jquery.com/) ● Lighttpd – lightweight open-source web server. (http://www.lighttpd.net/) ● Mysql – database engine (http://www.mysql.com)
  • 16. Adopted software ● Ngnix - A HTTP and mail proxy server licensed under a 2-clause BSD-like license. (http://nginx.org/) ● Fully working ngnix config provided. For eshop requirements and standard
  • 17. Building process – core ● Gallery core is based on eZ Components. Used components: – Authentication – Configuration – Database – Feed – ImageAnalysis – ImageConversion – PersistentObject – Translation – Cache – Url – UserInput
  • 18. Fulltext search implementation ● Why sphinx? – Very very fast :) ● Used features of 9.9 – SetSelect – this feature was introduced in 9.9 version and allowed to make fancy filtering. – Example in next slide
  • 19. Image full mode problem with previous and next image ● Search condition in literal. I need to find 2 previous images based on current image position including search keyword, sorting mode. ● ● URL consists of – Current image ID (16679) – Keyword (haposai) – Sort mode (popular) ● How do I find out what should I display in two first thumbnails (middle image is current our image)? ●
  • 20. Solution ● Use SetSelect query $cl->SetSelect ( "*, (hits > '.$Image->hits.' OR (hits = '.$Image->hits.' AND pid > '.$Image- >pid.')) AS myfilter" ); $cl->SetFilter ( "myfilter", array(1) ); ● Things I do not know how to do till now. If sorting is based on relevance how to now previous two images. ● I know now. But: – SetSelect does not work with @weight attributes in it. – Had to use two query's. SetFilter() works with @weight – AddQuery comes in help here for perfromance. Mutch more relevance images now.
  • 21. Some search statistic ● Each day around 190 K querys. It were more if search result page were not be cached :) ●
  • 22. Mysql performance tweaking ● Just optimise querys (EXPLAIN is you friend) ● Not a single slow query ● Some tips: – With large data sets use – SELECT * FROM `lh_gallery_images` – INNER JOIN ( SELECT pid FROM lh_gallery_images ORDER BY comtime DESC, pid DESC LIMIT 20 OFFSET 20 ) AS items – ON lh_gallery_images.pid = items.pid – This query is at least 5x times faster than normal select. Tested with (150 K records.) – See - http://www.mysqlperformanceblog.com
  • 23. Supported HTTP servers ● Lighttpd ● Apache ● Ngnix – With ngnix managed to produce around 1200 Q/S on cached page. It's 30% more than with Lighttpd.
  • 24. Caching objects ● Version caching – http://www.bestechvideos.com/2009/03/21/railslab-scaling-rails-episode-8-memcached – http://www.infoq.com/presentations/lutke-rockstar-memcaching – Version cache were used in ● Album pages ● Last uploaded ● Last hits ● Popular images and so on. ● The most popular images in 24 hours – Then cache is cleared? ● It's not, only version number is increased, and automatic cache self expire, because cache key does not exists. –
  • 25. Some code with version cache ● Cache Key calculation in Album ● $cache = CSCacheAPC::getMem(); $cacheKey = md5('version_'.$cache->getCacheVersion('album_'.(int)$Params['user_parameters']['album_id']). $mode.'album_view_url'.(int)$Params['user_parameters']['album_id'].'_page_'.$Params['user_parameters_unordered']['page']); – Includes: ● Album version ● $mode – sorting mode (Ex. Popular) ● Page this combination gives unique cache version for each page. ● Same logic applies to all listing pages
  • 26. Some benchmarks[root@ks310613 ~]# ab -n 500 -c 10 http://animeonly.org/Fantasy/Mix-16a.html 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 Server Hostname: animeonly.org Server Port: 80 Document Path: /Fantasy/Mix-16a.html Document Length: 26883 bytes Concurrency Level: 10 Time taken for tests: 0.545137 seconds Complete requests: 500 Failed requests: 0 Write errors: 0 Total transferred: 13593092 bytes HTML transferred: 13441500 bytes Requests per second: 917.20 [#/sec] (mean) Time per request: 10.903 [ms] (mean) Time per request: 1.090 [ms] (mean, across all concurrent requests) Transfer rate: 24349.84 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 5 10 2.9 9 23 Waiting: 4 9 3.1 9 23 Total: 5 10 2.9 9 23 Percentage of the requests served within a certain time (ms) 50% 9 66% 12 75% 13 80% 13 90% 13 95% 13 98% 20
  • 27. Etag base caching ● What is it? – An ETag (entity tag) is part of HTTP, the protocol for the World Wide Web. It is a response header that may be returned by an HTTP/1.1 compliant web server and is used to determine change in content at a given URL (http://en.wikipedia.org/wiki/HTTP_ETag)
  • 28. How to use it? $ExpireTime = 3600; $currentKeyEtag = md5($cacheKey.'user_id_'.erLhcoreClassUser::instance()->getUserID());; header('Cache-Control: max-age=' . $ExpireTime); // must-revalidate header('Expires: '.gmdate('D, d M Y H:i:s', time()+$ExpireTime).' GMT'); header('ETag: ' . $currentKeyEtag); $iftag = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] == $currentKeyEtag : null; if ($iftag === true) { header ("HTTP/1.0 304 Not Modified"); header ('Content-Length: 0'); exit; } ● $cacheKey – from previous example cache key ● User ID is needed if user is logged in. ● Can be used for custom pages, that do not change ● Then image is uploaded or deleted, we just increase cache version and Etag is expired automatic also. ●
  • 29. Some MRTG screen shots 1 ● Hits per hour ● ● ● Mysql queries ●
  • 30. Some MRTG screen shots 2 ● Memcached status ● ● ● Traffic stats ●
  • 31. Conclusions ● Single server with sphinx, memcached, mysql, nginx handles per day around 180 K pageviews daily. ● No performance issues at this time. ● Gallery home page http://code.google.com/p/hppg/
  • 32. Thank you for your attention :) ● Questions etc: – remdex@gmail.com