Php day 2011 - Zing me configuration system arch

16
Zing Me Configuration System Architecture Nguyen Quang Nam Zing Me Team

Transcript of Php day 2011 - Zing me configuration system arch

Page 1: Php day 2011 - Zing me configuration system arch

Zing Me Configuration System Architecture

Nguyen Quang NamZing Me Team

Page 2: Php day 2011 - Zing me configuration system arch

Content

Why

Introduction

Designs

1

3

2

Q&A4

Page 3: Php day 2011 - Zing me configuration system arch

Introduction

Page 4: Php day 2011 - Zing me configuration system arch

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

Why

Page 6: Php day 2011 - Zing me configuration system arch

- 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

Designs

Page 8: Php day 2011 - Zing me configuration system arch

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

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

- 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

- 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

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

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

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

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

Page 16: Php day 2011 - Zing me configuration system arch

Q & A

Contact:Nguyễn Quang [email protected]://me.zing.vn/nam.nq