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 lasts about 1 minute • Bikes leave a trail • Stats for each player are tracked across rounds • Players steer up/down/left/right • Play a few games, then come back later to see if you still hold • Hit any obstacle, trail, or player, the top spot and you’re out!
Overall Design UI (Angular) Non-Java frontend Player Service Game Service (REST) (REST + websockets) Auth Service SSO providers DB (REST) (Google, Twitter, GitHub)
Overall Design UI (Angular) CPU + I/O intensive Player Service Game Service (REST) (REST + websockets) Auth Service SSO providers DB (REST) (Google, Twitter, GitHub)
Overall Design UI (Angular) Internal REST calls Player Service Game Service (REST) (REST + websockets) Auth Service SSO providers DB (REST) (Google, Twitter, GitHub)
Overall Design UI (Angular) Persistent data Player Service Game Service (REST) (REST + websockets) Auth Service SSO providers DB (REST) (Google, Twitter, GitHub)
Overall Design UI (Angular) External REST calls Player Service Game Service (REST) (REST + websockets) Auth Service SSO providers DB (REST) (Google, Twitter, GitHub)
Overall Design UI (Angular) Single-Sign On auth Player Service Game Service (REST) (REST + websockets) Auth Service SSO providers DB (REST) (Google, Twitter, GitHub)
Benefits of Microservices Architecture • Independently scale services UI (Angular) Player Service (REST + (REST + (REST) websockets) (REST + websockets) (REST + Game Service websockets) websockets) (REST + websockets) Auth Service SSO providers DB (REST)
Benefits of Microservices Architecture • Independently scale services UI (Angular) • Develop services independently Game Service Player Service v1 (REST + (REST) websockets) Auth Service SSO providers DB (REST)
Benefits of Microservices Architecture • Independently scale services UI (Angular) • Develop services independently Game Service • Continuous delivery/deployment Player Service (REST + (REST) websockets) Auth Service SSO providers DB (REST)
Benefits of Microservices Architecture • Independently scale services UI (Angular) • Develop services independently Game Service • Continuous delivery/deployment Player Service (REST + (REST) websockets) • Language/framework freedom Auth Service SSO providers DB (REST)
Benefits of Microservices Architecture • Independently scale services UI (Angular) • Develop services independently Game Service • Continuous delivery/deployment Player Service (REST + (REST) websockets) • Language/framework freedom Auth Service • Fault/security isolation SSO providers DB (REST)
Difficulties of Microservices Architecture • Lots of service-service calls • MP Rest Client + JAX-RS • More points of failure • MP Fault Tolerance • Reconfigure for dev/prod • MP Config • Handling authentication • MP JWT
The tech stack
8
Configure required features Liberty server.xml includes the needed features
Rest Client GET https://github.com/login/oauth/access_tokenclient_id=foo&client_secret=foo&…
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
MicroProfile Fault Tolerance • @Retry • @Timeout 3x • @CircuitBreaker Game Service Player Service (REST + (REST) websockets) • @Fallback DB
MicroProfile Config Optional Required $ export auth_url=https://production.com/auth-service Override $ export github_key=superSecret java.util.NoSuchElementException: CWMCG0015E: Validation The property foo was not found in the configuration
JSON Web Tokens (JWT) { eyJhbGciOiJIUzI1NiI “alg”: “RS256”, header sInR5cCI6IkpXVCJ9. “typ”: “JWT” eyJzdWIiOiIxMjM0N } { TY3ODkwIiwibmFtZS “iss”: “libertybikes.com”, I6IkpvaG4gRG9lIiwia payload “sub”: “Andy”, ”groups”: [ “admin”, “user” ], WF0IjoxNTE2MjM5M … DIyfQ.VfiYwvArp2lN } V6UgpwgqrqfbJp9Q RS256( signature BASE64(header), pMdv07M8ZI4u4Vkw BASE64(payload), liFtz67lkDF8keyGciql secret)
JSON Web Tokens (JWT) • Many different libs • Each supports different claims
MicroProfile JWT BASIC CUSTOM
MicroProfile OpenAPI
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
Recommend
More recommend