databases suck for messaging · 2020. 10. 1. · few million messages/day) and implemented it in...

35
1 Databases suck for Messaging Alexis Richardson Oxford Geek Night May 2009

Upload: others

Post on 17-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

1

Databases suck for MessagingAlexis Richardson

Oxford Geek Night May 2009

Page 2: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Computers were meant to get rid of this

2

Page 3: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

A new kind of fail?

3

Page 4: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Solution - use a database?

4

Page 5: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Databases were meant to get rid of this too

5

Page 6: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

6

I want to know when THIS changes

Page 7: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Problem - databases suck for messaging

DATA is facts (“state”) persisted on disk

Databases are great for storing facts and asking questions about them

If you know what to ask them and are willing to keep asking them

INFORMATION is always changing

Networks are great pushing changes (“messages”) to recipients

Databases are not optimised for this

7

Page 8: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Social applications store data

8

Page 9: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Social applications store data

9

And there’s terabytes of it

Page 10: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Social applications store data

10

And there’s terabytes of it

Enterprises are made of people too So: the same issues arise

Page 11: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

11

I want to know when THIS changes

Page 12: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Email doesn’t scale

12

Page 13: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Information gets old - real quick

13

Page 14: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

But current information is valuable

14

Page 15: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Example: Flickr

Flickr is a vast database of social objects

Filtered by interest and relationships

So - tell me what’s currently relevant

Without sending me more emails....

15

Page 16: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Polling sucks

16

Page 17: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

What’s going on here? We are trapped in the database world view

17

Example due to Brett Slatkin and Brad Fitzpatrick at Googlehttp://code.google.com/p/pubsubhubbub/wiki/WhyPollingSucks

Page 18: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

How do we defeat this evil?

18

Page 19: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Can we apply the Hollywood Principle?

19

Page 20: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Can we apply the Hollywood Principle?

20

Hint: phone calls and SMS don’t travel through databases

Page 21: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Email push is direct

21

to:blaine“blah”alexis blaine

Page 22: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Email push is direct

22

to:blaine“blah”alexis blaine“blah”“blah”“blah”“blah”

Page 23: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Polling is just reverse spam

23

to:alexis“?”“?”“?”“?”“?”

alexis blaine

Page 24: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Publishing to a queue (“topic”) takes the spam burden off the receiver

24

alexis blaine

“blah”“blah”“blah”“blah”“blah”

topic: “from alexis”

PUSH PUSHfilterauth

Page 25: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

And you can use pubsub and queues in all sorts of ways

25

Page 26: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Databases are not meant to do Pubsub

26

SELECT * FROM queue WHERE done = 0 ORDER BY created LIMIT 1

Page 27: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

A true story

most people would just create a simple "queue" table

and: SELECT * FROM queue WHERE done = 0 ORDER BY created LIMIT 1

“concurrency issues on that thing now - inserting into the queue occasionally takes longer than doing the task that needs to be executed synchronously”

“middle management did not want to have "new third party software" because it would be too much Operations to learn and manage”

so they decided for the time being a MySQL based queue would be sufficient (only few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, and more hours because of performance issues ..

so i think we have spent about the same amount of time as we would to get a descent thing up and running, but now we're stuck with a lame and unscalable mysql database machines that is dressed as a message broker

27

Page 28: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Flickr from a Pubsub point of view

Flickr = people publishing to a vast set of streams (photostreams)

Users express interest through subscription

I don’t need to see everything - only changes on what I follow

This seems better - but what’s missing?- I am still trapped by the database world view. - I still poll for changes (that’s what RSS does)- I want the PUSH that email gave me, without the spam.....

28

Page 29: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

Characteristics of PUBSUB

A means of authenticated communication (network transport) - eg HTTP, OAuth

An addressable place to publish to - Usually a topic, feed, endpoint or address.

A way to name, enrol, share, and discover these addressable places- For example “[email protected]” or - TBD!

A way to deliver and ack delivery (or “take responsibility”)

The above is in fact a distributed object system

29

Page 30: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

How do you solve a problem like Flickr/Twitter/...

30

Data Objects serialised as rows in tables

Messages organised into streams

Interest Filter by query Durable “follow”

Notification Pull(polling sucks!)

Push

Buffering(non-idempotent)

Put = add row to tableGet = delete top row

PUT and GET are symmetric

Scale Overheads tend to grow indefinitely

Data flows out to destinations

Database Pubsub/MQ

Page 31: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

You might need messaging if ... you need to monitor data feeds

31

(CC) Kishore Nagarigari

Page 32: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

You might need messaging if ... you need a message delivered responsibly

32

Page 33: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

You might need messaging if ... you need things done in order

33

(CC) David Mach

Page 34: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

You might need messaging if ... you are using the cloud

34

Page 35: Databases suck for Messaging · 2020. 10. 1. · few million messages/day) and implemented it in PHP/MySQL resulting in lots of dev hours for implementation / testing, ... database

RabbitMQ is a messaging server that just works!

35

Thank you!

Im in yr serverz,queueing yr messagezPhoto credit: http://flickr.com/photos/53366513@N00/67046506/

copyright (c) Rabbit Technologies Ltd.