Slide 1

Slide 1 text

Laravel at Gousto A JOURNEY INTO MICROSERVICES

Slide 2

Slide 2 text

Overview Introduction History of Tech at Gousto Why microservices? Current stack Dive into Laravel at Gousto The future

Slide 3

Slide 3 text

Introduction

Slide 4

Slide 4 text

About me Principal Engineer Platform & Capabilities lead Backend COG lead Using Laravel for 4 years

Slide 5

Slide 5 text

About Gousto Recipe-kit company Founded 2012 Choose from 22 recipes on web/apps Order for delivery 7 days a week Measured ingredients delivered – no waste Rapidly growing business Diverse tech requirements Everything needed yesterday

Slide 6

Slide 6 text

A brief history

Slide 7

Slide 7 text

In the beginning… Front-end (website) Back-end (API)

Slide 8

Slide 8 text

Web Site (PHP Laravel) Business Logic (PHP Laravel) Users CMS Users Data Scientists Reporting Read Replica Production Database MySQL MySQL Tightly Coupled APIs

Slide 9

Slide 9 text

Strategy Cross-functional teams (squads) Own verticals of functionality No single team owns a service COGs ensure uniformity and best practices across services Pull out functionality into new service when developing new feature Account management Delivery management Marketplace Logged-in customers Sign-up Cookbook Menu Non logged-in customers Internal tooling Order processing Data engineering Capabilities

Slide 10

Slide 10 text

The benefits Performance + stability Quicker + frequent deployments Independence for teams Iterative development 0 5 10 15 20 25 30 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Week 8 Week 9 Week 10 Week 11 Week 12 Week 13 Week 14 Week 15 Week 16 Week 17 Week 18 Week 19 Week 20 Week 21 Week 22 Week 23 Week 24 Week 25 Week 26 Week 27 Week 28 Week 29 Week 30 Week 31 Week 32 Week 33 Weekly Production Deployments core fe platform gateway products auth gifts admin maintenance

Slide 11

Slide 11 text

The challenges Greater devops overhead ◦ More services => more alerts! Log aggregation ◦ AWS Cloudwatch still fairly basic Request tracing ◦ Where did this request originate? Orchestration Latency Larger AWS footprint

Slide 12

Slide 12 text

How Lumen helped Familiarity Lightweight Easy to bootstrap Simple to extend with packages Native support for AWS features Great community and ecosystem Fantastic documentation!

Slide 13

Slide 13 text

Current stack

Slide 14

Slide 14 text

Current stack React-based FE clients ◦ Server + client-side Nginx API gateway Lumen 5.2 microservices ◦ 15 in production ◦ 600k+ requests/day ◦ ~50ms avg. response time Memcache MySQL

Slide 15

Slide 15 text

Current stack Hosted in AWS Standardised “platform” ◦ Infrastructure as code – no configuration required ◦ Additional resources through additions Messaging platform ◦ Pub-sub model using SNS + SQS ◦ Automatic wiring to topics/queues based on service.yml src ansible cloudFormation service.yml roles overrides additions playbook.yml Service Repository

Slide 16

Slide 16 text

Dive in

Slide 17

Slide 17 text

Architecture auth service service b service c message bus service a microservice-comms messaging oauth cache chef vendor/gousto experiments src lumen business logic

Slide 18

Slide 18 text

Base Lumen service

Slide 19

Slide 19 text

Bootstrapping Uses composer create-project CLI interface to provide basic configuration Convention over configuration Provides shared libraries Just add routes…

Slide 20

Slide 20 text

Cross micro- service communication

Slide 21

Slide 21 text

Request flow Users service b route repository interface eloquent repository microservice repository eloquent model micro- service model presenter auth middleware controller service a

Slide 22

Slide 22 text

Microservice package

Slide 23

Slide 23 text

Microservice package Uses repository pattern and Eloquent model interface Declare a resource as a service Base repository and model ◦ Can be overridden per service Provides Collection and Paginator wrappers Uses API standards to construct request and provide parsed response

Slide 24

Slide 24 text

API standards REST API conventions ◦ Same internally and externally Standard for: ◦ REST URI structure ◦ JSON response schema ◦ HTTP methods and status codes ◦ Filtering + relations ◦ Sorting + pagination

Slide 25

Slide 25 text

Messaging

Slide 26

Slide 26 text

Customer Service Payment Service Delivery Service . . . I’ve changed address Got it, thanks.
1 3 2 4 SQS Client owned subscriptions SNS

Slide 27

Slide 27 text

Broadcasting Uses Laravel events and broadcasting contracts Triggered using event(…) Generates payload from messaging standard Events have option to override

Slide 28

Slide 28 text

Consuming Extends Laravel SQS queue functionality Queue workers automatically provisioned in base service Parse message body using messaging standard Route message to relevant event handler if present

Slide 29

Slide 29 text

Future work Logging standards Request tracing Docker

Slide 30

Slide 30 text

@GoustoTech techbrunch.gousto.co.uk [email protected]