5. Network (DNS)
Check whois is showing the right nameserver
whois openquery.com
NS1.LINODE.COM
NS2.LINODE.COM
NS3.LINODE.COM
NS4.LINODE.COM
NS1.CREATIVECONTINGENCIES.COM
NS2.CREATIVECONTINGENCIES.COM
NS3.CREATIVECONTINGENCIES.COM
Ensure correct record is returned by querying
each nameserver
dig www.openquery.com @ns1.creativecontingencies.com
13. HTTP Caching
Etag
Unique string – usual some form of digest
Browsers request with HTTP header:
If-None-Match: “uniquestring....”
Server response: 304 not modified if nothing
changes
20. Measurement (Application)
create table `timings` ( `id` int(4) NOT NULL
AUTO_INCREMENT, 'host' varchar(20),'page'
varchar(120), int t1,int t2, int t3.....)
And in the index.php
$sample = rand(0,100) < 5; # 5% sample rate
if ($sample) $t0 = microtime(TRUE);
21. Application Caching
Be strategic – cost / benefit
Hard to generate – graphs, database queries,
complex maths
Frequent pages: front pages, rss, ajax
22. Application Caching (duplicate)
if (!$db->count('name', $name,
DB_CACHE))
{
// if no cache entry exists, fetch the
appropriate html and insert
...
} else {
// row exists - determine if it is still valid
23. Application Caching
Cache an entire page
Memcache is your friend – RAM, autoexpire,
overload intelligent expire
Share between servers
Nice API in all languages
e.g. PHP
public mixed Memcached::get ( string $key [, callable
$cache_cb [, float &$cas_token ]] )
24. Application scaling
If the application scales by adding webservers
you will save on hosting on high power servers
Ensure application is stateless
Reverse proxy state-full bits to central server if
needed
CDNs or separated servers for static content
saves lots of cpu (latency, keep alives)
26. Database
Know what indexes are and which queries aren't
using them.
EXPLAIN {sql expression} (Postgresql and Mysql)
EXPLAIN ANALYSE {sql expression}
Slow query log – enable
Know differences between MySQL engines
Tune your server
Defaults well out of proportion with your sever.
27. Database (continued)
Searching text in SQL – Use Sphinxsearch
instead
Same sql interfaces, pulls off database – much
quicker at full text search
28. Databases (application)
Eventually one DB will be too little
Plan to buy big hardware (Oracle) or plan to use
a replicated database (for reads)
Some reads will need to occur on the master.
The ones where the data was likely just
changed very recently