"do you know those widgets that we made long time ago?
we'd like tham to go live"
...
"well we don't have exact numbers, but approximately
110 million views per month"
...
"hello, HELLO?"
widget == banner
Let see how many requests per second current solution can handle? Goal: ~45 req/s
#fail
code optimization
cache all DB queries
cache all Sphinx queries
sometimes it is better that requests don't even reach your application
- Tomicius
Rasimus
make your application generate whole page into cache
whole page, <html> to </html>
directly from memcached
or from redis
# widget nginx + memcached
location /widget/ {
set $memcached_key $geoip_city$uri;
if ($arg_company != '') {
set $memcached_key $memcached_key?company=$arg_company
}
default_type text/html;
memcached_pass 127.0.0.1:11211;
error_page 404 = @fallback;
expires +7200;
}
location @fallback {
proxy_pass http://apache.application.server:8081;
proxy_buffering off;
proxy_redirect off;
}
Let see how many requests per second current solution can handle?
Goal: ~45 req/s
wow. very fast. so much win.
with keepalive https://gist.github.com/gjuric/7580148
:( values too big to have described effect
our main problem was distance information
4. by IP address (approx. to much)
3. by town (1145)
2. by region (9)
1. whole Austria
come to me with solution, don't come to me with problem
use triple constraint - cost, time, scope
quality
VPS, 4 cores, 8 GB RAM
load barely noticeable
36 million req/month
peaks 50-60 req/second
additional memcache fallback
upstream memcached_backed {
server 192.168.1.1:11211;
server 192.168.1.2:11211;
}
# widget nginx + memcached
location /widget/ {
memcached_pass memcached_backed;
memcached_next_upstream error;
}
Varnish, Edge Side Includes, web accelerators...
use Geohash for key
let's reverse this geohash to see how it works
comunicate with your colleagues, devops, hosting guys, clients, bosses...
cache stampede & cache warm up
google analytics
keep your cache alive
@tomyz0r, @ivedrna, @msvrtan, @goran_juric, @trikoder and many others
do you skip leg day?
being the best developer is not enough