Extrait du cours scripting libdrizzle with Lua inside Nginx
Business Background
● Linezing data analysis product
○ Provides consumer/sales analysis service for Taobao shops
○ Mainly presents various data reporting pages to end-user
○ Rapidly grows up:
● Currently 2.3M active shops, 3k more per day
● TCP conns(/min/box): 3.75k/62.69k/109k(min/avg/max)
● Daily PV per box: >30M
● Only 4 FE boxesin total
Architecture Evolution
Pros
● Std LAMP, well understood
● Easy to learn for newcomers Cons
● Repeatedly transfer page outline
● Limited concurrency
● Slow-connection attack risk
● PHP is slow for large data processing
Solution
● Using different web serving paradigm
○ Blocking process/thread v.s. Event driven FSM
● Put invariant resources to CDN
● Filling page content at browser-side instead of server-side
○ Implement business logic using Javascript
○ AJAX communication
Architecture (improved)
Pros
● Saved bandwith
● Reduced server load
● Improved concurrency
● Immune to slow-connection attack
Cons
● Less productive on developing
● PHP/FastCGI restricted overall throughput
Solution
● Need efficient accessing to MySQL in Nginx
○ ngx_drizzle was developed!
● Need productive programming language fitting Nginx I/O model
○ ngx_lua was developed!
ngx_drizzle intro
● Accessing MySQL in Nginx in non-blocking synchronous manner
● Keepalive, pooling connections with loadbalancing
● Convert query result to JSON/CSV directly through ngx_rds_json/csv modules
……….
Scripting libdrizzle with Lua inside Nginx (1059 KO) (Cours PDF)