Beyond relational databaseBuilding high performance website usingRedis and PHPPham Cong Dinh                   Hanoi PHP D...
What I am talking about               •     Relational database in our world               •     High performance web apps...
Relational database in our world                                  •    Question                                        • H...
Relational database in our world                          •     Brewers (CAP) Theorem                                •   C...
Relational database in our world                          •     BASE: An ACID Alternative                                •...
Relational database in our world                          •     Relational database in high performance                   ...
High performance web apps: new             challenges                                  •    Web server is bottleneckPart  ...
High performance web apps: new      challenges                          •     Database is bottleneckGo beyond relational d...
High performance web apps: new      challenges                          •     CPU is bottleneckGo beyond relational database
High performance web apps: new      challenges                          •     More requests: going distributed is easy    ...
High performance web apps: new      challenges                          •     Scaling for READ is easier for scaling for  ...
REDIS: A data structure datastore                                  •    Redis (REmote DIctionary Server)                  ...
REDIS: A data structure datastore                          •     In a most basic form, it is a key – value                ...
REDIS: A data structure datastore                          •     Database concept                                •   SELEC...
REDIS: A data structure datastore                          •     Key => Value                                •   SET mykey...
REDIS: A data structure datastore                          •     LIST                                •   RPUSH mylistkey s...
REDIS: A data structure datastore                          •     SET                                •   SADD mysetkey memb...
Redis PHP clients                               •    Owlients phpredis                                    •   Can be found...
Any question?Phần 4    Go beyond relational database
Upcoming SlideShare
Loading in...5
×

redis

472

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
472
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "redis"

  1. 1. Beyond relational databaseBuilding high performance website usingRedis and PHPPham Cong Dinh Hanoi PHP Day 2009Software Developer December 19, 2009Vega Corporation
  2. 2. What I am talking about • Relational database in our world • High performance web apps: new challenges • Redis: A data structure store • Using some of Rediss PHP clients 90 80 70 60 East 50 West 40 North 30 South 20 10 0Go beyond relational database 1st Qtr 2nd Qtr 3rd Qtr 4th Qtr
  3. 3. Relational database in our world • Question • How can we store our data? • AnswerPart 1 • Relational database • ACID is our love • Atomicity - all parts of a transaction succeed or none of then succeed. Integrity. • Consistency - Nothing in your transaction will violate the rules of the database. Integrity. • Isolation - Each transaction operates independently of every other transaction. • Durability - Once the database says that data is committed there is no opportunity for that to be undone. Go beyond relational database
  4. 4. Relational database in our world • Brewers (CAP) Theorem • C: Consistency - The client perceives that a set of operations has occurred all at once. • Strong consistency: ACID • A: Availability - Every operation must terminate in an intended response. Requests are to be served even when there is a partition in the cluster. • P: Partition tolerance - Operations will complete, even if individual components are unavailable.Go beyond relational database
  5. 5. Relational database in our world • BASE: An ACID Alternative • Basically Available • Soft state • Eventually consistent. • Data partitioning and decision between Consistency and Availability.Go beyond relational database
  6. 6. Relational database in our world • Relational database in high performance environments • Google • Facebook • Wikipedia • Live Journal • Yahoo FAILED? • … but most companies does not need more than a single database server • … but modern web apps today is facing a real challengeGo beyond relational database
  7. 7. High performance web apps: new challenges • Web server is bottleneckPart 2 Go beyond relational database
  8. 8. High performance web apps: new challenges • Database is bottleneckGo beyond relational database
  9. 9. High performance web apps: new challenges • CPU is bottleneckGo beyond relational database
  10. 10. High performance web apps: new challenges • More requests: going distributed is easy • Apache • PHP • Database scalability is hard • Struggling with SMP: MySQL • Replication is hard: replication is single threaded: MySQL • Most relational databases find hard to scale WRITEs • Schema constraints • Disk I/O • Memory constraints • Global lock • Complicated data typesGo beyond relational database
  11. 11. High performance web apps: new challenges • Scaling for READ is easier for scaling for WRITE mysql> select count(1) from setacc; +----------+ | count(1) | +----------+ | 3982438 | +----------+ 1 row in set (0.00 sec) mysql> select count(1) from setacc_del; +----------+ | count(1) | +----------+ | 4003793 | +----------+ 1 row in set (0.00 sec)Go beyond relational database
  12. 12. REDIS: A data structure datastore • Redis (REmote DIctionary Server) • Network interface to language dependent client library: Python, Java, Ruby, Erlang,Part 3 C# … • Written in C • Latest version: 1.1 Go beyond relational database
  13. 13. REDIS: A data structure datastore • In a most basic form, it is a key – value store: think Memcached • Not memory only • Not immediately durable • Supports set of complicated data structure • Can be found at http://code.google.com/p/redis/Go beyond relational database
  14. 14. REDIS: A data structure datastore • Database concept • SELECT indexGo beyond relational database
  15. 15. REDIS: A data structure datastore • Key => Value • SET mykey myvalue • GET mykey • More: MGET, MSET •Go beyond relational database
  16. 16. REDIS: A data structure datastore • LIST • RPUSH mylistkey string • LPUSH mylistkey string • LLEN mylistkey • LPOP mylistkey • RPOP mylistkey • More: LGET/LSET ...Go beyond relational database
  17. 17. REDIS: A data structure datastore • SET • SADD mysetkey member • SREM key member • Sorted SETGo beyond relational database
  18. 18. Redis PHP clients • Owlients phpredis • Can be found at http://github.com/owlient/phpredisPhần 4 • C extension Go beyond relational database
  19. 19. Any question?Phần 4 Go beyond relational database

×