Stuff I do - Janos Pasztor · glb.techblog.cloud. IN ALIAS us-west-1.glb.techblog.cloud. Hosting...

Post on 16-Oct-2020

0 views 0 download

Transcript of Stuff I do - Janos Pasztor · glb.techblog.cloud. IN ALIAS us-west-1.glb.techblog.cloud. Hosting...

Stuff I do

Follow me!

https://pasztor.at

@janoszen

About this talk

1. The problem with CDNs

About this talk

1. The problem with CDNs

2. How does a CDN work?

About this talk

1. The problem with CDNs

2. How does a CDN work?

3. Static content CDN

About this talk

1. The problem with CDNs

2. How does a CDN work?

3. Static content CDN

4. Hosting dynamic content

Assumptions

You know what HTTP is.

Assumptions

You know what HTTP is.

You know what a DNS is.

Assumptions

You know what HTTP is.

You know what a DNS is.

You know what a CDN is.

Warning!

Don’t do this at home!This is as experimental as it gets.

The problem with CDNs

Low-traffic sites don’t work well with a CDN

The problem with CDNs

The problem with CDNs

The problem with CDNs

The problem with CDNs

The problem with CDNs

The problem with CDNs

The problem with CDNs

The problem with CDNs

The problem with CDNs

The problem with CDNs

User CDN Origin

GET /avatar.jpg

Cache

The problem with CDNs

User CDN Origin

GET /avatar.jpg

Cache

The problem with CDNs

User CDN Origin

GET /avatar.jpg

Cache

GET /avatar.jpg

The problem with CDNs

User CDN OriginCache

GET /avatar.jpg

GET /avatar.jpg

The problem with CDNs

User CDN Origin

GET /avatar.jpg

Cache

GET /avatar.jpg

The problem with CDNs

User CDN OriginCache

GET /avatar.jpg

The problem with CDNs

User CDN OriginCache

~30-40 ms ~160 ms

The problem with CDNs

User CDN OriginCache

~30-40 ms ~160 ms

~30-40 ms~10 ms

The problem with CDNs

User CDN OriginCache

~30-40 ms ~160 ms

~160 ms

~30-40 ms~10 ms

The problem with CDNs

User CDN OriginCache

~30-40 ms ~160 ms

~160 ms~160 ms

~200 ms

~50 ms~30-40 ms

~10 ms

The problem with CDNs

Workaround:

The problem with CDNs

Workaround:

Cache-Control: s-maxage=31536000

The problem with CDNs

Caveat:

All files must have unique URLs!

Does not always work.

How do CDNs work?

Locating the properedge node

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

I have 1.2.3.4!

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

I have 1.2.3.4!

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

I have 1.2.3.4!

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

1.2.3.4

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

1.2.3.4

I have 1.2.3.4!

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

1.2.3.4

I have 1.2.3.4!

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

1.2.3.4I have 1.2.3.4!

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

1.2.3.4

I have 1.2.3.4!

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

1.2.3.4

I have 1.2.3.4!

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

1.2.3.4

I have 1.2.3.4!

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

1.2.3.4

1.2.3.4

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

1.2.3.4

1.2.3.4

3 hops

6 hops

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA1.2.3.4 1.2.3.4

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA1.2.3.4 1.2.3.410.1.0.1 10.2.0.1

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA1.2.3.4 1.2.3.410.1.0.1 10.2.0.1

What is the IP for pasztor.at?

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA1.2.3.4 1.2.3.410.1.0.1 10.2.0.1

10.1.0.1

How do CDNs work?

User

CDN POP in Europe CDN POP in the USA

Anycast is ONLY used for DNS lookups!

See https://engineering.linkedin.com/network-performance/tcp-over-ip-anycast-pipe-dream-or-reality

Hosting static content

Part 1:Finding a DNS provider

Hosting static content

Anycast servers

Hosting static content

Anycast servers

Latency- or GeoIP based responses

Hosting static content

Anycast servers

Latency- or GeoIP based responses

Hosting static content

eu-central-1.glb.techblog.cloud. IN A 18.194.241.96

us-east-1.glb.techblog.cloud. IN A 54.152.113.29

us-west-1.glb.techblog.cloud. IN A 52.9.244.13

Hosting static content

eu-central-1.glb.techblog.cloud. IN A 18.194.241.96

us-east-1.glb.techblog.cloud. IN A 54.152.113.29

us-west-1.glb.techblog.cloud. IN A 52.9.244.13

glb.techblog.cloud. IN ALIAS eu-central-1.glb.techblog.cloud.

glb.techblog.cloud. IN ALIAS us-east-1.glb.techblog.cloud.

glb.techblog.cloud. IN ALIAS us-west-1.glb.techblog.cloud.

Hosting static content

Hosting static content

Part 2:Docker

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance My laptopEC2 instanceEC2 instance

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

ECS AGENT

My laptop

ECSECSECS

EC2 instance

ECS AGENT

EC2 instance

ECS AGENT

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

ECS AGENT

WEB SERVER

My laptop

ECSECSECS

EC2 instance

ECS AGENT

WEB SERVER

EC2 instance

ECS AGENT

WEB SERVER

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

ECS AGENT

WEB SERVER

My laptop

ECSECSECS

EC2 instance

ECS AGENT

WEB SERVER

EC2 instance

ECS AGENT

WEB SERVER

ECR

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

ECS AGENT

WEB SERVER

My laptop

ECRECSECSECS

EC2 instance

ECS AGENT

WEB SERVER

EC2 instance

ECS AGENT

WEB SERVER

Docker Image

Webserver Content

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

ECS AGENT

WEB SERVER

My laptop

ECRECSECSECS

EC2 instance

ECS AGENT

WEB SERVER

EC2 instance

ECS AGENT

WEB SERVER

Docker Image

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

ECS AGENT

WEB SERVER

My laptop

ECSECSECS

EC2 instance

ECS AGENT

WEB SERVER

EC2 instance

ECS AGENT

WEB SERVER

Docker Image

ECR

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

ECS AGENT

WEB SERVER

My laptop

ECRECSECSECS

EC2 instance

ECS AGENT

WEB SERVER

EC2 instance

ECS AGENT

WEB SERVER

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

WEB SERVER

My laptop

ECR

EC2 instance

WEB SERVER

EC2 instance

WEB SERVER

ECS AGENT

ECSECSECS

ECS AGENT

ECS AGENT

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

WEB SERVER

My laptop

ECSECSECS

EC2 instance

WEB SERVER

EC2 instance

WEB SERVER

ECS AGENT

ECR

ECS AGENT

ECS AGENT

Hosting static content

us-west-1 us-east-1 eu-central-1

EC2 instance

ECS AGENT

WEB SERVER

My laptop

ECRECSECSECS

EC2 instance

ECS AGENT

WEB SERVER

EC2 instance

ECS AGENT

WEB SERVER

Hosting dynamic content

Can it run Wordpress?

Hosting dynamic content

us-west-1 us-east-1 eu-central-1

EC2 instanceEC2 instanceEC2 instance

Hosting dynamic content

us-west-1 us-east-1 eu-central-1

EC2 instanceEC2 instanceEC2 instance

INTERNET

Hosting dynamic content

us-west-1 us-east-1 eu-central-1

EC2 instanceEC2 instanceEC2 instance

INTERNET

Docker Swarm Overlay Network

Hosting dynamic content

us-west-1 us-east-1 eu-central-1

EC2 instanceEC2 instanceEC2 instance

INTERNET

WEB SERVER

WEB SERVER

WEB SERVER

Hosting dynamic content

us-west-1 us-east-1 eu-central-1

EC2 instanceEC2 instanceEC2 instance

INTERNET

WEB SERVER

WEB SERVER

WEB SERVERGALERA GALERA GALERA

Hosting dynamic content

Hosting dynamic content

Unsolved issues:

Hosting dynamic content

Unsolved issues:

Distributing Static Content

Hosting dynamic content

Unsolved issues:

Distributing Static Content

Downtime-less Updates

Hosting dynamic content

Unsolved issues:

Distributing Static Content

Downtime-less Updates

Monitoring

Summary

Is it worth it?

Summary

Summary

Summary

Summary

Summary

Probably not.

Summary

Questions?

Many thanks to

Bence Sántha, Dan Radenković, Gábor Vereb, János Angeli, Krisztián Papp

for their inspiration and feedback.