LIBERTY BIKES An online game for 1-4 players Built on microservices - - PowerPoint PPT Presentation

liberty bikes
SMART_READER_LITE
LIVE PREVIEW

LIBERTY BIKES An online game for 1-4 players Built on microservices - - PowerPoint PPT Presentation

LIBERTY BIKES An online game for 1-4 players Built on microservices What is Liberty Bikes? What is Liberty Bikes? Objective: be the last player alive Join a game by entering a code Bikes move at the same speed Each round


slide-1
SLIDE 1

LIBERTY BIKES

An online game for 1-4 players Built on microservices

slide-2
SLIDE 2

What is Liberty Bikes?

slide-3
SLIDE 3

What is Liberty Bikes?

  • Objective: be the last player alive
  • Bikes move at the same speed
  • Bikes leave a trail
  • Players steer up/down/left/right
  • Hit any obstacle, trail, or player,

and you’re out!

  • Join a game by entering a code
  • Each round lasts about 1 minute
  • Stats for each player are tracked

across rounds

  • Play a few games, then come

back later to see if you still hold the top spot

slide-4
SLIDE 4

Player Service (REST) Auth Service (REST) Game Service

(REST + websockets)

DB UI (Angular)

Overall Design

SSO providers (Google, Twitter, GitHub)

Non-Java frontend

slide-5
SLIDE 5

Player Service (REST) Auth Service (REST) Game Service

(REST + websockets)

DB UI (Angular)

Overall Design

SSO providers (Google, Twitter, GitHub)

CPU + I/O intensive

slide-6
SLIDE 6

Player Service (REST) Auth Service (REST) Game Service

(REST + websockets)

DB UI (Angular)

Overall Design

SSO providers (Google, Twitter, GitHub)

Internal REST calls

slide-7
SLIDE 7

Player Service (REST) Auth Service (REST) Game Service

(REST + websockets)

DB UI (Angular)

Overall Design

SSO providers (Google, Twitter, GitHub)

Persistent data

slide-8
SLIDE 8

Player Service (REST) Auth Service (REST) Game Service

(REST + websockets)

DB UI (Angular)

Overall Design

SSO providers (Google, Twitter, GitHub)

External REST calls

slide-9
SLIDE 9

Player Service (REST) Auth Service (REST) Game Service

(REST + websockets)

DB UI (Angular)

Overall Design

SSO providers (Google, Twitter, GitHub)

Single-Sign On auth

slide-10
SLIDE 10

Benefits of Microservices Architecture

Player Service (REST) Auth Service (REST) (REST + websockets) SSO providers DB UI (Angular)

  • Independently scale services

(REST + websockets) (REST + websockets) (REST + websockets) Game Service (REST + websockets)

slide-11
SLIDE 11

Benefits of Microservices Architecture

Player Service v1 (REST)

Auth Service (REST) Game Service (REST + websockets) SSO providers DB UI (Angular)

  • Independently scale services
  • Develop services independently
slide-12
SLIDE 12

Benefits of Microservices Architecture

Player Service (REST) Auth Service (REST) Game Service (REST + websockets) SSO providers DB UI (Angular)

  • Independently scale services
  • Develop services independently
  • Continuous delivery/deployment
slide-13
SLIDE 13

Benefits of Microservices Architecture

Player Service (REST) Auth Service (REST) Game Service (REST + websockets) SSO providers DB UI (Angular)

  • Independently scale services
  • Develop services independently
  • Continuous delivery/deployment
  • Language/framework freedom
slide-14
SLIDE 14

Benefits of Microservices Architecture

Player Service (REST) Auth Service (REST) Game Service (REST + websockets) SSO providers DB UI (Angular)

  • Independently scale services
  • Develop services independently
  • Continuous delivery/deployment
  • Language/framework freedom
  • Fault/security isolation
slide-15
SLIDE 15

Difficulties of Microservices Architecture

  • Lots of service-service calls
  • More points of failure
  • Reconfigure for dev/prod
  • Handling authentication
  • MP Rest Client + JAX-RS
  • MP Fault Tolerance
  • MP Config
  • MP JWT
slide-16
SLIDE 16

The tech stack

slide-17
SLIDE 17

8

slide-18
SLIDE 18

Configure required features

Liberty server.xml includes the needed features

slide-19
SLIDE 19

Rest Client

GET https://github.com/login/oauth/access_tokenclient_id=foo&client_secret=foo&…

slide-20
SLIDE 20

MicroProfile Rest Client

GET https://github.com/ login/oauth/ access_token ?client_id=foo&client_secret=foo&…

  • Dorg.libertybikes.auth.service.github.GitHubOAuthAPI/mp-rest/url=https://github.com
slide-21
SLIDE 21

MicroProfile Fault Tolerance

Player Service (REST) Game Service (REST + websockets) DB

3x

  • @Retry
  • @Timeout
  • @CircuitBreaker
  • @Fallback
slide-22
SLIDE 22

MicroProfile Config

$ export auth_url=https://production.com/auth-service $ export github_key=superSecret

Required Optional Override

java.util.NoSuchElementException: CWMCG0015E: The property foo was not found in the configuration

Validation

slide-23
SLIDE 23

JSON Web Tokens (JWT)

eyJhbGciOiJIUzI1NiI sInR5cCI6IkpXVCJ9. eyJzdWIiOiIxMjM0N TY3ODkwIiwibmFtZS I6IkpvaG4gRG9lIiwia WF0IjoxNTE2MjM5M DIyfQ.VfiYwvArp2lN V6UgpwgqrqfbJp9Q pMdv07M8ZI4u4Vkw liFtz67lkDF8keyGciql

payload

{ “alg”: “RS256”, “typ”: “JWT” } { “iss”: “libertybikes.com”, “sub”: “Andy”, ”groups”: [ “admin”, “user” ], … } RS256( BASE64(header), BASE64(payload), secret)

header signature

slide-24
SLIDE 24

JSON Web Tokens (JWT)

  • Many different libs
  • Each supports

different claims

slide-25
SLIDE 25

MicroProfile JWT

BASIC CUSTOM

slide-26
SLIDE 26

MicroProfile OpenAPI

slide-27
SLIDE 27

Where To Get It

You can play hosted Liberty Bikes here: (DE) libertybikes-frontend.eu-de.mybluemix.net (UK) libertybikes-frontend.eu-gb.mybluemix.net (US) libertybikes.mybluemix.net Or, clone our repository and run it locally: github.com/liberty-bikes/liberty-bikes