Web 2.0 网站架构、优化 数据库架构

PHP, Python Consistent Hashing(一致性hash)

import memcache
import binascii
m = memcache.Client(['192.168.28.7:11211', '192.168.28.8:11211
', '192.168.28.9:11211'])

def php_hash(key):
    return (binascii.crc32(key) >> 16) & 0x7fff

for i in range(30):
       key = 'key' + str(i)
       a = m.get((php_hash(key), key))
       print i, a

6个开源利器

Web Caches
nginx Very powerful and efficient web server and reverse proxy
Varnish Cache Web accelerator written with performance and flexibility in mind
Squid High-performance proxy caching server and web cache daemon
Traffic Server High-performance building block for cloud services
Polipo Fast and lightweight caching web proxy
eAccelerator PHP accelerator and optimizer derived from the MMCache extension
返回顶部