dino esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · not because of...

28
Dino Esposito dotNEXT St.Petersburg Common Scalability Practices that just work

Upload: others

Post on 27-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Dino Esposito

dotNEXT St.Petersburg

Common Scalability Practices that just work

Page 2: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Scalability as teenage sex

▪ Everyone talks about it ▪ Nobody really knows how to do it ▪ Everyone thinks everyone else is doing it ▪ So everyone claims they are doing it...

Yes

YesMmm

NEED

Page 3: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Domain and app matching

No product or technology can magically make a system scalable and usable.

▪ Not because you save data to the cloud, your app survives thousands of concurrent users.

▪ Not because of HTML5 users will enjoy the application.

Page 4: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Scalability

System's ability to handle a growing number of requests without incurring in significant performance loss and failures.

Scalability became a problem with the advent of web

Page 5: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Queuing theory

A queue forms when frequency at which requests for a service are placed exceeds the time it takes to fully serve a pending request.

❑ It’s about the performance of a single task ❑ It’s about expanding the system to perform more tasks at

the same time

Page 6: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Ensure the system…

▪ Doesn’t crash at launch ▪ Gives signs of degrading performance timely

Make sure you know the most common tools and strategies to address scalability needs.

Page 7: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Strategies

Page 8: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Vertical vs. Horizontal

Page 9: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Vertical

Norm for 20 years – so long as DB was central point Doesn’t scale beyond a point

Front caching is a good way to do it • Proxy servers with load balancing capabilities • Working outside the core code of the application • Squid, Varnish, Nginx

Page 10: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Horizontal

Mostly an architectural point

Critical parts can be expanded without • Damaging other parts • Introducing inconsistencies / incongruent data

Page 11: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Horizontal

LOAD BALANCING

MULTIPLE INSTANCES

DATA SHARDING

Page 12: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Real-world

Cloud apps are probably the easiest and most effective way to achieve forms of scalability today.

But, at the same time, you can have well responsive apps without re-architecting for the cloud.

Page 13: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Common Practices

Page 14: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Operational Practice #1

Remove bottlenecks • Convoluted queries • Long initialization steps • Inefficient algorithms

HIGH throughput

MEDIUM cost

TIME consuming

DELICATE

Page 15: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Operational Practice #2

Move “some” requests to other servers • CDN for static files • Geographically distributed sites

LOW throughput

LOW cost

Quick

Improves the user’s perception of the system

Page 16: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Operational Practice #3

Output Caching • By param • By locale • By custom data

for example, multi-tenant sites

MEDIUM throughput

LOW cost

Quick

MEDIUM risk

Page 17: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Operational Practice #4

Data Caching • Problematic with farms • Auto-updatable internal cache • Use of distributed caches Redis, ScaleOut, NCache

HIGH throughput

MEDIUM cost

Relatively Quick

DELICATE

Page 18: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Operational Practice #5

Proxy caching for example Varnish • Installed in front of any web site • Fully configurable • Cache and load balancer in one

HIGH throughput

Relatively LOW cost

Relatively Quick

Page 19: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Architectural Practice #1

CQRS Architecture ▪ Optimize stacks differently HIGH throughput

HIGH cost

Time consuming

Page 20: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Presentation layer

Application layer

Infrastructure layer

Canonical layered architecture

Domain layer

Presentation layer

Application layer

Infrastructure layer

CQRS

Commands Queries

Domain layer

Data access

+ DTO

Message-based business logic implementation

Page 21: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

BUSINESS DOMAIN

Command Context #1

Query Context #1

Command Context #2

Query Context #2

Command Context #3

Query Context #3

CQRS DesignDDD Analysis

CONTEXT #1

CONTEXT #2

CONTEXT #3

Requirements

Page 22: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Architectural Practice #2

Single-tier and stateless server • One server • No session state • Quick and easy to duplicate • Behind a load balancer

HIGH throughput

Low cost

Quick

Page 23: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

The point of the cloud

Page 24: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Architectural Practice #3

Cloud support ▪ On-demand servers ▪ Pay per use ▪ Configure easily ▪ No middleware costs ▪ Better failure policies

Page 25: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

DISTRIBUTED CACHESERVERSERVER

SERVERSERVERDISTRIBUTED

CACHECACHE

PERSISTENT

Auto-update internal cache Global cache

Page 26: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Architectural Practice #4

Session state out of the server • Client cookies if applicable • Distributed cache • Azure blob storage

HIGH throughput

MEDIUM cost

Relatively quick

Tricky

PS: Best option for ASP.NET is probably using the Redis-based provider for out-of-process session state.

Page 27: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

Architectural Practice #5

Be aware of NoSQL and polyglot persistence • Relational is OK … until it works • Sharding/growth of data

Azure SQL + Many small tables <500GB each + No extra license costs + Zero TCO + HA automatically on

SQL Server in a VM + Fewer large tables >500GB each + Reuse existing licenses + More machine resources + HA and management is your own

Page 28: Dino Esposito - public.jugru.orgpublic.jugru.org/dotnext/2015/piter/dino.pdf · Not because of HTML5 users will enjoy the application. ... • Problematic with farms • Auto-updatable

FOLLOW

That’s All Folks!

facebook.com/naa4e

software2cents.wordpress.com

[email protected]

@despos

Copyright Dino Esposito 2015