Back to front – Backend technologies for the frontend developer

A presentation at Droidcon London in October 2022 in London, UK by Savvas Dalkitsis

Slide 1

Slide 1

Back to front Backend technologies for the frontend developer @geeky_android@androiddev.social

Slide 2

Slide 2

Who am I? Savvas Dalkitsis (he/him) Principal Software Engineer @ASOS @geeky_android@androiddev.social

Slide 3

Slide 3

ASOS

Slide 4

Slide 4

Why am I here? @geeky_android@androiddev.social

Slide 5

Slide 5

ad b An dro id @geeky_android@androiddev.social MVVMR Retrofit xJa v t a P MV er UI Pla l i H Da gg m o y Ro ose mp Co C te se Ma eba Fir le d gra Jet pa ck I MV ogle nes Go uti oro rial ite sql Studio

Slide 6

Slide 6

ng eri nd ~re de ~si ver ser n ind sql no co nta i ne rs jwt g kin loc ic~ ist tim op s dn ch ao s~m on key cd sal t uth oa ep ote nc y ingress~controller u ion q ~ ct e g un a s f s e m @geeky_android@androiddev.social es oki co ed non~blo ge cking ~ ~io g sw r e a t s ork eRt clu ers oun s e s d~ eu rob in

Slide 7

Slide 7

So what? @geeky_android@androiddev.social

Slide 8

Slide 8

Language barriers are real in tech too. Progressing your career means being able to have meaningful discussions with people outside your domain and comfort zone. A basic understanding of their language is paramount. Source: cartoonresource/Adobe Stock @geeky_android@androiddev.social

Slide 9

Slide 9

Let’s start @geeky_android@androiddev.social

Slide 10

Slide 10

Caching There are only two hard things in Computer Science: cache invalidation and naming things. Phil Karlton @geeky_android@androiddev.social

Slide 11

Slide 11

Caching Expiry headers @geeky_android@androiddev.social

Slide 12

Slide 12

@geeky_android@androiddev.social

Slide 13

Slide 13

@geeky_android@androiddev.social

Slide 14

Slide 14

Caching Server side controlled expiry @geeky_android@androiddev.social

Slide 15

Slide 15

Caching Server side controlled expiry Expires header Example Expires: Wed, 21 Oct 2015 07:28:00 GMT @geeky_android@androiddev.social

Slide 16

Slide 16

Caching Server side controlled expiry Cache-Control header Example Cache-Control: max-age=604800 @geeky_android@androiddev.social

Slide 17

Slide 17

The following table lists the standard Cache-Control directives: Request Response Request Response max-age max-age

must-revalidate max-stale

proxy-revalidate min-fresh

must-understand

s-maxage

private no-cache no-cache

public no-store no-store

immutable no-transform no-transform

stale-while-revalidate only-if-cached

stale-if-error stale-if-error _ https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control @geeky_android@androiddev.social

Slide 18

Slide 18

Caching ETags @geeky_android@androiddev.social

Slide 19

Slide 19

What is an ETag? The ETag (or entity tag) HTTP response header is an identifier for a specific version of a resource. It lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content was not changed. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag @geeky_android@androiddev.social

Slide 20

Slide 20

ETag = Unique Resource ID Example ETag: “33a64df551425fcc55e4d42a148795d9f25f89d4” @geeky_android@androiddev.social

Slide 21

Slide 21

Example If-None-Match: “33a64df551425fcc55e4d42a148795d9f25f89d4” @geeky_android@androiddev.social

Slide 22

Slide 22

ETag Mid air conflicts @geeky_android@androiddev.social

Slide 23

Slide 23

@geeky_android@androiddev.social

Slide 24

Slide 24

Example: If-Match: “33a64df551425fcc55e4d42a148795d9f25f89d4” @geeky_android@androiddev.social

Slide 25

Slide 25

Caching CD-eh? @geeky_android@androiddev.social

Slide 26

Slide 26

@geeky_android@androiddev.social

Slide 27

Slide 27

Caching Server side rendered pages @geeky_android@androiddev.social

Slide 28

Slide 28

@geeky_android@androiddev.social

Slide 29

Slide 29

Caching Multilayered caching @geeky_android@androiddev.social

Slide 30

Slide 30

@geeky_android@androiddev.social

Slide 31

Slide 31

Web Application/API Design @geeky_android@androiddev.social

Slide 32

Slide 32

Web Application/API Design REST Give it a REST @geeky_android@androiddev.social

Slide 33

Slide 33

REST is a set of architectural constraints, not a protocol or a standard. API developers can implement REST in a variety of ways. https://www.redhat.com/en/topics/api/what-is-a-rest-api @geeky_android@androiddev.social

Slide 34

Slide 34

Web Application/API Design HTTP Verbs Oh CRUD @geeky_android@androiddev.social

Slide 35

Slide 35

Does this look familiar? https://my.awesome/api/people/1/addAddress https://my.awesome/api/people/1/getAddress https://my.awesome/api/people/1/changeAddress https://my.awesome/api/people/1/deleteAddress @geeky_android@androiddev.social

Slide 36

Slide 36

https://my.awesome/api/people/1/ add Address https://my.awesome/api/people/1/ get Address https://my.awesome/api/people/1/ change Address https://my.awesome/api/people/1/ delete Address @geeky_android@androiddev.social

Slide 37

Slide 37

HTTP verbs, REST resources nouns POST https://my.awesome/api/people/1/ address GET https://my.awesome/api/people/1/ address PUT https://my.awesome/api/people/1/ address DELETE https://my.awesome/api/people/1/ @geeky_android@androiddev.social address

Slide 38

Slide 38

Web Application/API Design Query parameters http://i.already/know?about=those @geeky_android@androiddev.social

Slide 39

Slide 39

TL;DR; If you ever see this in your api: https://something.or.other/login?username=rick&password=pickle from the mountaintops @geeky_android@androiddev.social

Slide 40

Slide 40

Web Application/API Design JWT wtj? @geeky_android@androiddev.social

Slide 41

Slide 41

@geeky_android@androiddev.social

Slide 42

Slide 42

Web Application/API Design OAuth oh oh ffff… @geeky_android@androiddev.social

Slide 43

Slide 43

Why OAuth? Remember this? https://something.or.other/login?username=rick&password=pickle @geeky_android@androiddev.social

Slide 44

Slide 44

@geeky_android@androiddev.social

Slide 45

Slide 45

@geeky_android@androiddev.social

Slide 46

Slide 46

@geeky_android@androiddev.social

Slide 47

Slide 47

Web Application/API Design Idempotency @geeky_android@androiddev.social

Slide 48

Slide 48

@geeky_android@androiddev.social

Slide 49

Slide 49

ETags 2 - Return of the UUID? @geeky_android@androiddev.social

Slide 50

Slide 50

If we follow the REST principles in designing our APIs, we will have automatically idempotent REST APIs for GET, PUT, DELETE, HEAD, OPTIONS, and TRACE methods. Only POST APIs will not be idempotent. POST is NOT idempotent. GET , PUT , DELETE , HEAD , OPTIONS and TRACE are idempotent. https://restfulapi.net/idempotent-rest-apis/ @geeky_android@androiddev.social

Slide 51

Slide 51

Service topology @geeky_android@androiddev.social

Slide 52

Slide 52

Containers! Photo by Ian Taylor on Unsplash

Slide 53

Slide 53

@geeky_android@androiddev.social

Slide 54

Slide 54

Service topology Microservices @geeky_android@androiddev.social

Slide 55

Slide 55

@geeky_android@androiddev.social

Slide 56

Slide 56

@geeky_android@androiddev.social

Slide 57

Slide 57

@geeky_android@androiddev.social

Slide 58

Slide 58

Service topology DNS @geeky_android@androiddev.social

Slide 59

Slide 59

Service topology Clusters @geeky_android@androiddev.social

Slide 60

Slide 60

Service topology Traffic Managers / Ingress controllers @geeky_android@androiddev.social

Slide 61

Slide 61

https://my.awesome.service/home https://my.awesome.service/product/123 https://my.awesome.service/search?q=jeans @geeky_android@androiddev.social

Slide 62

Slide 62

Load balancers Image by Peggy und Marco Lachmann-Anke from Pixabay @geeky_android@androiddev.social

Slide 63

Slide 63

Service topology Multi-primary replication @geeky_android@androiddev.social

Slide 64

Slide 64

Chaos @geeky_android@androiddev.social

Slide 65

Slide 65

Honorable mentions @geeky_android@androiddev.social

Slide 66

Slide 66

Edge workers Functions Message queues - Event Driven Architecture Optimistic Locking Eventual Consistency NoSQL Non blocking sysIO Round Robin Encryption at rest/In transit - End to End Encryption Salting Eventual Consistency @geeky_android@androiddev.social

Slide 67

Slide 67

Q&A Raffle @geeky_android@androiddev.social Slides https://github.com/ASOS/presentation-back-to-front