Slide 1

Slide 1 text

Scaling iParadigms with PostgreSQL Richard Yen - iParadigms, LLC PGWest 2010

Slide 2

Slide 2 text

What is iParadigms?

Slide 3

Slide 3 text

What is iParadigms? Small Internet company in downtown Oakland, established in 1996

Slide 4

Slide 4 text

What is iParadigms? Small Internet company in downtown Oakland, established in 1996 Creators of Turnitin.com, the leading provider of academic integrity services to schools and universities worldwide

Slide 5

Slide 5 text

What is iParadigms? Small Internet company in downtown Oakland, established in 1996 Creators of Turnitin.com, the leading provider of academic integrity services to schools and universities worldwide Creators of iThenticate.com, an up-and-coming service for publications and journals

Slide 6

Slide 6 text

Nearly 180,000 paper submissions per day

Slide 7

Slide 7 text

7,000 active accounts opened by schools and universities

Slide 8

Slide 8 text

Nearly 40,000 new users per day

Slide 9

Slide 9 text

Some more stats

Slide 10

Slide 10 text

Some more stats Over 3000 Queries per second across entire Turnitin replication cluster--approx. 1,000 transactions per second

Slide 11

Slide 11 text

Some more stats Over 3000 Queries per second across entire Turnitin replication cluster--approx. 1,000 transactions per second Turnitin grew from 90GB to 110GB on disk since beginning of 2010

Slide 12

Slide 12 text

How did we get here?

Slide 13

Slide 13 text

Why Postgres?

Slide 14

Slide 14 text

Why Postgres? FREE

Slide 15

Slide 15 text

Why Postgres? FREE Transaction support

Slide 16

Slide 16 text

Why Postgres? FREE Transaction support Referential Integrity

Slide 17

Slide 17 text

Why Postgres? FREE Transaction support Referential Integrity Triggers

Slide 18

Slide 18 text

Why Postgres? FREE Transaction support Referential Integrity Triggers Constraints

Slide 19

Slide 19 text

Why Postgres? FREE Transaction support Referential Integrity Triggers Constraints Robust

Slide 20

Slide 20 text

Why Postgres? FREE Transaction support Referential Integrity Triggers Constraints Robust Active community support

Slide 21

Slide 21 text

Pitfalls

Slide 22

Slide 22 text

Pitfalls Needed replication to sustain performance Scalability Load distribution

Slide 23

Slide 23 text

Pitfalls Needed replication to sustain performance Scalability Load distribution Lack of replication put system at risk as SPOF No failover No quick recovery

Slide 24

Slide 24 text

Slony-I Replication Engine

Slide 25

Slide 25 text

Slony Features

Slide 26

Slide 26 text

Slony Features Replication from master to multiple slaves

Slide 27

Slide 27 text

Slony Features Replication from master to multiple slaves Lightweight and fast

Slide 28

Slide 28 text

Slony Features Replication from master to multiple slaves Lightweight and fast Fairly robust

Slide 29

Slide 29 text

Slony Features Replication from master to multiple slaves Lightweight and fast Fairly robust Supports complex replication architectures

Slide 30

Slide 30 text

How Slony fits in

Slide 31

Slide 31 text

How Slony fits in Provided load distribution Replication asynchronous -- wrote our own Multiplexor to use slaves as read-only copies

Slide 32

Slide 32 text

How Slony fits in Provided load distribution Replication asynchronous -- wrote our own Multiplexor to use slaves as read-only copies Failover/Switchover Provided recovery plan -- whew! Enabled easy upgrades

Slide 33

Slide 33 text

How Slony fits in Provided load distribution Replication asynchronous -- wrote our own Multiplexor to use slaves as read-only copies Failover/Switchover Provided recovery plan -- whew! Enabled easy upgrades Delayed replication

Slide 34

Slide 34 text

How Slony fits in Provided load distribution Replication asynchronous -- wrote our own Multiplexor to use slaves as read-only copies Failover/Switchover Provided recovery plan -- whew! Enabled easy upgrades Delayed replication Log Shipping (will discuss in a bit)

Slide 35

Slide 35 text

Still Problems

Slide 36

Slide 36 text

Still Problems Slony not very scalable

Slide 37

Slide 37 text

Still Problems Slony not very scalable Cannot handle 10+ slave nodes

Slide 38

Slide 38 text

Still Problems Slony not very scalable Cannot handle 10+ slave nodes System begins to crumble

Slide 39

Slide 39 text

Still Problems Slony not very scalable Cannot handle 10+ slave nodes System begins to crumble Network traffic becomes a problem

Slide 40

Slide 40 text

Still Problems Slony not very scalable Cannot handle 10+ slave nodes System begins to crumble Network traffic becomes a problem Each connection consumes DB resources

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Quick Fixes

Slide 50

Slide 50 text

Quick Fixes Employed log-shipping to reduce traffic to colocation

Slide 51

Slide 51 text

Quick Fixes Employed log-shipping to reduce traffic to colocation

Slide 52

Slide 52 text

Quick Fixes Employed log-shipping to reduce traffic to colocation

Slide 53

Slide 53 text

Quick Fixes

Slide 54

Slide 54 text

Quick Fixes Segregated services Put Turnitin, TurnitinUK, and iThenticate on separate clusters Upgraded hardware to keep #nodes to a minimum (instead of horizontal scaling)

Slide 55

Slide 55 text

Further Improvements

Slide 56

Slide 56 text

Further Improvements Moved to Solid-State Disk

Slide 57

Slide 57 text

Further Improvements Moved to Solid-State Disk 90% of traffic is SELECT traffic

Slide 58

Slide 58 text

Further Improvements Moved to Solid-State Disk 90% of traffic is SELECT traffic FusionIO drives improved SELECT performance on index tremendously

Slide 59

Slide 59 text

SSD v. Spindle Comparison Host tii-master (150GB SSD) tii-slave1 (300GB SSD) tii-slave2 (225GB RAID1-0) pgfouine queries/s 3450 1753 1825 iostat tps 155.9224605 189.1772031 413.4493879 iostat blk_w/s 983.9365667 936.4881394 859.8786056 iostat blk_r/s 2698.912213 2021.420332 8650.986441 # of 30sec samples 2466 2466 2466 Specs Storage Type 2 FusionIO RAID0 2 FusionIO RAID0 RAID-10 spindle RAM 64GB 64GB 64GB CPU 8x Xeon 3.00GHz 16x Xeon 2.67GHz 8x Xeon 3.00GHz Avg Load (15 min) 4.3 1.92 3.34 Avg CPU iowait (%) 0.495457861 0.23653706 3.013296881

Slide 60

Slide 60 text

More Reasons for SSD

Slide 61

Slide 61 text

More Reasons for SSD Lower power consumption

Slide 62

Slide 62 text

More Reasons for SSD Lower power consumption Increases rack space real estate

Slide 63

Slide 63 text

More Reasons for SSD Lower power consumption Increases rack space real estate Short-stroking RAID drives provides almost equal performance at similar cost

Slide 64

Slide 64 text

More Reasons for SSD Lower power consumption Increases rack space real estate Short-stroking RAID drives provides almost equal performance at similar cost Price of SSD is dropping!

Slide 65

Slide 65 text

More Reasons for SSD Lower power consumption Increases rack space real estate Short-stroking RAID drives provides almost equal performance at similar cost Price of SSD is dropping! Planning to move to Virident shortly

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

Current Challenges

Slide 69

Slide 69 text

Current Challenges Connection capacity

Slide 70

Slide 70 text

Current Challenges Connection capacity Improving our Multiplexor

Slide 71

Slide 71 text

Current Challenges Connection capacity Improving our Multiplexor Integrating pgBouncer

Slide 72

Slide 72 text

Current Challenges Connection capacity Improving our Multiplexor Integrating pgBouncer Data set continues to grow

Slide 73

Slide 73 text

Current Challenges Connection capacity Improving our Multiplexor Integrating pgBouncer Data set continues to grow Need to find a way to partition/shard

Slide 74

Slide 74 text

Current Challenges Connection capacity Improving our Multiplexor Integrating pgBouncer Data set continues to grow Need to find a way to partition/shard Postgres stats helps much in pruning the data set

Slide 75

Slide 75 text

Current Challenges Connection capacity Improving our Multiplexor Integrating pgBouncer Data set continues to grow Need to find a way to partition/shard Postgres stats helps much in pruning the data set Need a long-term capacity management plan

Slide 76

Slide 76 text

Lessons Learned XID wraparound -- make sure you have space in pg_xlog! table bloat -- don’t let autovacuum bite you (8.4 resolves this) slony failover not working -- found race condition idle transactions -- keep an eye on them

Slide 77

Slide 77 text

Lessons Learned RAID config -- Use the right RAID level, and keep your pg_xlog on a separate partition Slony log-shipping -- very versatile and useful

Slide 78

Slide 78 text

Lessons Learned

Slide 79

Slide 79 text

Lessons Learned Postgres is very robust, very scalable

Slide 80

Slide 80 text

Lessons Learned Postgres is very robust, very scalable Third-party software like Slony and PgBouncer are very reliable

Slide 81

Slide 81 text

Lessons Learned Postgres is very robust, very scalable Third-party software like Slony and PgBouncer are very reliable Mailing list and IRC chat are very useful

Slide 82

Slide 82 text

Q & A

Slide 83

Slide 83 text

The End