Zing Me Configuration System Architecture Nguyen Quang Nam Zing Me Team
May 15, 2015
Zing Me Configuration System Architecture
Nguyen Quang NamZing Me Team
Content
Why
Introduction
Designs
1
3
2
Q&A4
Introduction
Some info:
- Servers: ~700
- ZiDB: ~115 instances
- Memcached: ~80 instances
- MySQL: ~20 instances
- Cassandra: ~8 instances
- Others: Gearman, Scribe, HBase, ZiHttpd, ZiProxy, ..: many many
How to manage?
Why
- Too many services to keep in your head - Auto synchronize configuration changes
- C/C++/Java/PHP (or any) apps can share same configurations
Designs
System design
ZooKeeper servers
Gift Appon Zing Me
(PHP)
Zing MeWidget(Java)
C/C++ Backendservice
Rep
Read conf Read conf
Sync
“Bạn tôi nghe gì”Box
(Java)
Read conf
ServicesMap
server
Modules design
ServicesMap(Nonblocking server)
ZKsync
App
Public Singleton ConfSet
Get Changed
Conf Scheduler
Upd
ZKsSync
SHM ConfSet
Update SHM Agent
Read confUpd conf
Read changed conf
App
PHP Java
Admin
ConfSet Extension
- Written in C++
- NonblockingServer with Thrift interface
- Cache: hash table data structure with zallocator is designed to reduce memory fragmentation
- Persistent DB: ZiDB core
- Very high performance: 180K reads per second
ServicesMap
- Written in C++
- Agent is scheduled to read only changed config from ServicesMap
- SHM ConfSet is on Shared Memory
- SHM ConfSet contains double buffer to store both old & new conf
Agent & SHM ConfSet
ConfSet Extension
- Written in C & C++
- Provide APIs for PHP app to access SHM ConfSet
APC?
- Access APC from PHP: 120K reads per second
- Access SHM ConfSet using ConfSet Extension from PHP: 250K reads per second
- So hard to build my own module to access APC
- APC can be accessed from any PHP application
PHP to ServicesMap?
- Direct access through a TCP connection: <10K reads per second
- ServicesMap is dead, nothing can works
- Network is slow, anything can works?
Agents Monitoring
Agent ServicesMap
Register
Expiration time
Get changed conf
Changed conf
Unregister
OK
- ServicesMap manages all agents
- Each agent in ServicesMap has 2 state Active or Dead
- Each agent in ServicesMap has a last sync time field, and an expiration time duration
- ServicesMap exposes APIs for Admin module getting all agents and states
Q & A
Contact:Nguyễn Quang [email protected]://me.zing.vn/nam.nq