Unibet.com Architecture Open Source at Unibet.com: 10x scalability - - PowerPoint PPT Presentation

unibet com architecture
SMART_READER_LITE
LIVE PREVIEW

Unibet.com Architecture Open Source at Unibet.com: 10x scalability - - PowerPoint PPT Presentation

Unibet.com Architecture Open Source at Unibet.com: 10x scalability at half the cost stefan.norberg@unibet.com @stnor About the speaker Unibet Open Source strategy Open source software and open standards should always be our first choice


slide-1
SLIDE 1

Unibet.com Architecture

Open Source at Unibet.com: 10x scalability at half the cost stefan.norberg@unibet.com @stnor

slide-2
SLIDE 2

About the speaker

slide-3
SLIDE 3

Unibet Open Source strategy

slide-4
SLIDE 4
  • Open source software and open standards should

always be our first choice

  • Avoid vendor lock-in - software we use should have a

right-to-use license without any cost attached

slide-5
SLIDE 5
  • Commercial, proprietary software need to show

exceptional business value (over Free solutions) in order to be considered

  • Contribute to the community by buying support from

companies backing FOSS solutions or paying for product improvements

slide-6
SLIDE 6

Betting Engine Messaging Customers Async Betting API Web CMS REST API:s Partners & Affiliates Payment Banners

Single-sign-on

Bonus System Wallet System Customer System

Browser Flash/Flex DDos Protection Content Deliver Networks Fan-out Push Servers Poker Casino Bingo

slide-7
SLIDE 7

Betting Engine Messaging Customers Async Betting API Web CMS REST API:s Partners & Affiliates Payment Banners

Single-sign-on

Bonus System Wallet System Customer System

Browser Flash/Flex DDos Protection Content Deliver Networks Fan-out Push Servers

slide-8
SLIDE 8

Unibet in numbers

  • 100% online - www.unibet.com
  • 30+ web sites in 27 languages
  • Gross win: 250 million dollars / year
  • “Technical” growth is >100% / year
slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12
slide-13
SLIDE 13
slide-14
SLIDE 14
slide-15
SLIDE 15
slide-16
SLIDE 16

Why is this hard?

slide-17
SLIDE 17

Because users are growing impatient

slide-18
SLIDE 18

2006: 4 seconds

Source: Juniper Research

slide-19
SLIDE 19

2009: 2 seconds

Source: Forrester Research

slide-20
SLIDE 20

Two main challenges

  • Latency - data too far away from where it’s

needed

  • Bottlenecks - resource contention
slide-21
SLIDE 21

Avg 40 ms RTT

slide-22
SLIDE 22

Meet Kevin

  • Kevin is a customer to the candy store
  • Kevin wants to buy 40 pcs for his allowance
  • Kevin has extremely small pockets (they
  • nly fit one piece of candy)
  • He also wants to buy two chocolate bars

and one bubble gum

  • The candy store is far far away from Kevin’s

house

slide-23
SLIDE 23
slide-24
SLIDE 24

Idea #1 Sell bags of candy

(Caveat: no bars or bubblegums in bags!)

slide-25
SLIDE 25
slide-26
SLIDE 26

The bag is a big JS file

slide-27
SLIDE 27

The bag is a big CSS file

slide-28
SLIDE 28

The bag is a CSS image sprite*

slide-29
SLIDE 29

/4.9.3/images/uskin1/uspritesheadertabs.png blackTab

slide-30
SLIDE 30

The 100% optimized e-commerce web page: 4 requests

HTML

Conn 1

CSS

JS Conn 2

250 ms 30 ms 250 ms

IMG

30 ms

Total time: 530 ms

slide-31
SLIDE 31

Some real world data

  • amazon.com: 57 requests (6)
  • ebay.com: 41 requests (4)
  • unibet.com: 41 requests (1)
slide-32
SLIDE 32

Ouch.

slide-33
SLIDE 33

Idea #2 Sell bags on street corners

(Caveat: no bars or bubblegums in bags!)

slide-34
SLIDE 34
slide-35
SLIDE 35

There are many street corners

slide-36
SLIDE 36

Street corners are very near all customers

slide-37
SLIDE 37

The street corner is a Content Delivery Network node

slide-38
SLIDE 38
slide-39
SLIDE 39

GOOD SPOT

35 ms avg latency

slide-40
SLIDE 40

BAD SPOT

70 ms avg latency

slide-41
SLIDE 41

BAD SPOT

Bandwidth Latency Redundancy Pricing

slide-42
SLIDE 42

Tune tune tune the front-end!

  • 80-90% of the end-user response time is

spent downloading and processing all the components in the page

  • Rewrote and optimized all our front-end

code (XHTML, CSS, JS)

  • Implemented image spriting and fixed other

issues with cache headers etc

slide-43
SLIDE 43

Tune tune tune the front-end!

  • Use best practice to optimize your front-

end (YSlow, Page Speed etc)

  • Progressive rendering is key
  • Improve performance by having objects

served close to the user

slide-44
SLIDE 44

http://www.webpagetest.org/

slide-45
SLIDE 45

How we do it

  • Follow

YSlow and Pagespeed guidelines

  • Be close to your users - use a Content

Delivery Network (CDN)

  • Prepend CDN proxy name to all static

files: /foo/bar -> http://cdn.com/foo/bar

  • Set a one year cache-time (no 304:s)
  • Version your static content
  • Stripe objects over several CNAMES
slide-46
SLIDE 46

NOT SO BAD SPOT

15 ms avg latency 10 ms avg latency 10 ms avg latency

slide-47
SLIDE 47
  • By using a CDN we serve our users quickly

from anywhere in the world

  • Capacity is not an issue
  • We have cut our delivery costs to 25%
  • Use several CDN vendors for load balancing /

redundancy

slide-48
SLIDE 48

Next steps...

slide-49
SLIDE 49

Live Betting data distribution

  • Bet while the game is on

“Who gets the next corner”, “who scores the next goal” etc

  • 10000:s of real-time clients need price

updates almost every second

  • 20 concurrent games
  • 10+ offers within one game
  • Product growth 60-80% per year
slide-50
SLIDE 50

Betting Engine

slide-51
SLIDE 51

Fan-out Server Fan-out Server

Betting Engine

slide-52
SLIDE 52

Betting Engine RabbitMQ

Rabbit MQ

Kaazing

Rabbit MQ

Kaazing

  • End-to-end messaging
  • RabbitMQ
  • Kaazing Enterprise Gateway
  • Google Protocol Buffers
slide-53
SLIDE 53

RabbitMQ

  • Free Open Source and Open Standards

protocol (AMQP)

  • Highly available, highly scalable (Erlang/OTP)
  • Excellent & friendly support available
slide-54
SLIDE 54

Kaazing

  • Open Source and Open Standards protocol

(HTML5 WebSockets)

  • Supported AMQP clients for Flex, browers
  • Connection offloading
  • Great at overcoming last mile hurdles

(firewalls, proxies, browsers)

  • Excellent & friendly support available
slide-55
SLIDE 55

Protocol Buffers

  • Flexible, efficient, automated mechanism for

serializing (binary)

  • Schema support (.proto files)
  • Language neutral (we use Java to Actionscript)
  • Invented and used by Google
  • Open Sourced in July 2008
slide-56
SLIDE 56

Java/ Spring

Fan-out node

AS3

Betting Engine Live Betting Client

RabbitMQ RabbitMQ Kaazing

Protobufs/AMQP

slide-57
SLIDE 57

Let’s get back to the Candy store...

slide-58
SLIDE 58

Datacenter

  • Ok, the candy delivery problem is solved!
  • However, we cannot serve the customers

chocolate and bubble gum quickly enough

  • Queues are building up due to our

bottlenecks

slide-59
SLIDE 59
slide-60
SLIDE 60

The chocolate bar is a cacheable read

slide-61
SLIDE 61

The bubble gum is a non-cacheable read or a write

slide-62
SLIDE 62

The candy store checkout is an app server

slide-63
SLIDE 63

The bubble gum machine is a database system

slide-64
SLIDE 64

Example #1 More hardware! (and sw licenses)

slide-65
SLIDE 65

Kids are invading our store...

slide-66
SLIDE 66
slide-67
SLIDE 67
slide-68
SLIDE 68
slide-69
SLIDE 69
slide-70
SLIDE 70
slide-71
SLIDE 71

paying per core is paying for peaks... ...is not acceptable?

Food for thought

slide-72
SLIDE 72
slide-73
SLIDE 73
slide-74
SLIDE 74

You cannot buy a product to solve this problem

slide-75
SLIDE 75

Need to rearchitect!

slide-76
SLIDE 76

Example #2 Near-cache

slide-77
SLIDE 77

Terracotta

  • Network Attached Memory
  • Extends the Java threading model across

JVM:s

  • In-memory speed access to data
  • Fully coherent, with stored to disk

guarantees

  • Writes are sent as deltas across nodes
slide-78
SLIDE 78

Keep data stored/cached where it’s needed for processing

Event Repository Bet Offer Repository Live Bets

Terracotta L2

Betting Engine Betting Engine Betting Engine

... Oracle (MySQL) JVM Heap “L1”

write-behind

SoR

Eventually consistent Reporting/ Legacy

slide-79
SLIDE 79

Keep data stored/cached where it’s needed for processing

Event Repository Bet Offer Repository Live Bets

Terracotta L2

Betting Engine Betting Engine Betting Engine

... Oracle (MySQL)

write-behind

update

JVM Heap “L1” SoR

Reporting/ Legacy

slide-80
SLIDE 80

Terracotta

  • L2 server can become bottleneck
  • Shard (free) or stripe ($$$)
slide-81
SLIDE 81

Example #3 Offload reads to separate systems

slide-82
SLIDE 82

Bet History

MySQL

History Server History Server

...

R R R Event Repository Bet Offer Repository Live Bets

Terracotta L2

Betting Engine Betting Engine Betting Engine

... Oracle (MySQL)

Backoffice

Settle Bet

slide-83
SLIDE 83

Example #4 Affinity + multi master replication

slide-84
SLIDE 84

Customer System Customer System Customer System Customer System

cus-client.jar user1 user2 user3

LDAP LDAP LDAP

cus-client.jar

LDAP

data center 2

user4

data center 1

slide-85
SLIDE 85

Example #5 Partition the data to scale writes

slide-86
SLIDE 86

Bet History routing

MySQL

History Server History Server

...

S1 S2 S3 Live Bets C C C

  • Need to get settlements

done quickly

  • More than 10000 writes / s
  • Scale out by using multiple

MySQL instances

slide-87
SLIDE 87
slide-88
SLIDE 88

Combining the pieces

slide-89
SLIDE 89

Betting Engine AMQP Broker (RabbitMQ)

Geo-distributed Fan-out Push Servers (Kaazing) Browser Betting Client Flash Betting Client HTML

Betting History Database (MySQL)

Shared memory for events, bet

  • ffers and customer bets

(Terracotta)

Betting Engine Betting Engine Account Servers

write-behind write-behind

  • n settlement

price updates and replies commands payouts Betting API History API sharded with local MySQL Settled bets 100% read Live data

slide-90
SLIDE 90

Recap: Two main challenges

  • Latency - data too far away from where it’s

needed

  • Bottlenecks - resource contention
slide-91
SLIDE 91

Recipes used at Unibet

  • Optimize your web apps!
  • Get rid of static object traffic
  • Move web data closer to customers (CDN)
  • Last-mile fan-out messaging

information delivery

slide-92
SLIDE 92

Recipes used at Unibet

  • Move data to business logic
  • Read-only farms
  • Multi-master replication for read-mostly

data

  • Sharding to scale writes

in the data center

slide-93
SLIDE 93

Open Source Software and Services is used by Unibet extensively in mission critical applications because...

slide-94
SLIDE 94

...we are convinced it’s better and more cost effective!

slide-95
SLIDE 95

Thanks!

(we’re hiring)

@stnor stefan.norberg@unibet.com stnor.wordpress.com www.linkedin.com/in/stnor

slide-96
SLIDE 96

Backup slides

slide-97
SLIDE 97

DDoS resilience

  • Outsourced DNS
  • DDoS protection service
slide-98
SLIDE 98
slide-99
SLIDE 99
slide-100
SLIDE 100

GRE tunnels

Unibet is here Unibet is here Unibet is here