![Page 1: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/1.jpg)
Zing Me Configuration System Architecture
Nguyen Quang NamZing Me Team
![Page 2: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/2.jpg)
Content
Why
Introduction
Designs
1
3
2
Q&A4
![Page 3: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/3.jpg)
Introduction
![Page 4: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/4.jpg)
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?
![Page 5: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/5.jpg)
Why
![Page 6: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/6.jpg)
- Too many services to keep in your head - Auto synchronize configuration changes
- C/C++/Java/PHP (or any) apps can share same configurations
![Page 7: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/7.jpg)
Designs
![Page 8: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/8.jpg)
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
![Page 9: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/9.jpg)
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
![Page 10: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/10.jpg)
- 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
![Page 11: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/11.jpg)
- 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
![Page 12: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/12.jpg)
ConfSet Extension
- Written in C & C++
- Provide APIs for PHP app to access SHM ConfSet
![Page 13: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/13.jpg)
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
![Page 14: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/14.jpg)
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?
![Page 15: Php day 2011 - Zing me configuration system arch](https://reader036.vdocument.in/reader036/viewer/2022062319/5554de7fb4c905a16f8b5321/html5/thumbnails/15.jpg)
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