80
ECONOMIES SCALING SOFTWARE OF Abdelmonaim Remani @PolymathicCoder [email protected] github.com/PolymathicCoder Josh Long @starbuxman [email protected] github.com/joshlong (之春)

Economies of Scaling Software

Embed Size (px)

DESCRIPTION

This talk introduces how to approach scaling applications.

Citation preview

Page 1: Economies of Scaling Software

E C O N O M I E S S C A L I N G S O F T WA R E

O F

Abdelmonaim Remani @PolymathicCoder

[email protected] github.com/PolymathicCoder

Josh Long @starbuxman

[email protected] github.com/joshlong

(⻰龙之春)

Page 2: Economies of Scaling Software

Spring Developer Advocate

@Starbuxman @PolymathicCoder

Josh Long (⻰龙之春)

@starbuxman [email protected]|

Jean Claude van Damme! Java mascot Duke some thing’s I’ve authored...

Page 3: Economies of Scaling Software

@Starbuxman @PolymathicCoder

Abdelmonaim Remani@PolymathicCoder [email protected] |

Page 4: Economies of Scaling Software

@Starbuxman @PolymathicCoder

Page 5: Economies of Scaling Software

BUILDING ADAPTIVE APPLICATIONS IS HARD

built on Cloud Foundry !code will be open sourced.

W H Y S C A L E ?

Page 6: Economies of Scaling Software

Moore’s Law no longer works@Starbuxman @PolymathicCoder

§ processing can’t scale up § concurrent, horizontal architectures are easier to scale

§ “process”-style concurrency is easy to scale still

Moore's law is the observation that, over the history of computing hardware, the number of transistors in a dense integrated circuit doubles approximately every two years. The law is named after Gordon E. Moore, co-founder of the Intel Corporation, who described the trend in his 1965 paper.!!http://en.wikipedia.org/wiki/Moore's_law

Page 7: Economies of Scaling Software

data@Starbuxman @PolymathicCoder

44000%larger in 2020 than 2009

data production is expected to be

:

Page 8: Economies of Scaling Software

systems are increasingly complex@Starbuxman @PolymathicCoder

§ a complex system today has a lot of moving parts § security

§ multiple clients (iOS, Android, Windows Mobile, etc.)

§ multiple (business) domains

§ integration between systems

§ requires more people working on the same problem

Page 9: Economies of Scaling Software

mobile

More than 1.5 MILLION activations daily *

@Starbuxman @PolymathicCoder

* http://www.androidcentral.com/larry-page-15-million-android-devices-activated-every-day

Page 10: Economies of Scaling Software

social: a connected world in 60 seconds@Starbuxman @PolymathicCoder

3125 photos uploaded 7630

messages sent

7610 searches 2MM

videos viewed

2000 checkins

175k tweets

1090 visitors

700k messages sent

* source: visual.ly/60-seconds-social-media

Page 11: Economies of Scaling Software

the internet of things@Starbuxman @PolymathicCoder

“In five years, by 2018, Earth will be home to 7.6 billion people, says the United Nations. By contrast, some 25 billion devices will be connected by 2015, and 50 billion by 2020, says Cisco.”!!http://www.businessinsider.com/what-you-need-to-know-about-the-internet-of-things-2013-3?op=1#ixzz3FxCafwWe

§ IPv6 gives us more addresses

§ devices are getting smaller, more ubiquitous

§ “devices” include homes appliances (refrigerators, washers, coffee machines, dryers), roads, air pollution monitors, (human) body monitors, etc

Page 12: Economies of Scaling Software

how to think about scale?@Starbuxman @PolymathicCoder

Chris Richardson (http://microservices.io/articles/scalecube.html) introduced me to this “scale cube” from The Art of Scaling Software

Page 13: Economies of Scaling Software

BUILDING ADAPTIVE APPLICATIONS IS HARD

built on Cloud Foundry !code will be open sourced.

X-AXIS H O R I Z O N TA L D U P L I C AT I O N

Page 14: Economies of Scaling Software

STATELESS APPSSCALE

Page 15: Economies of Scaling Software

no state and lots of gain@Starbuxman @PolymathicCoder

§ obvious: no state means no sharing

§ no sharing means that applications can be scaled horizontally easily

§ requires very little:

§ HTTP load balancers are ubiquitous.

§ message queues (like RabbitMQ) make effective load balancers

Page 16: Economies of Scaling Software

DEMO R A B B I T M Q P I N G P O N G

Page 17: Economies of Scaling Software

WHAT IF I HAVE SOME STATE?

Page 18: Economies of Scaling Software

http sessions? @Starbuxman @PolymathicCoder

§ Spring Session § useful in a PaaS

§ useful when you need state

§ useful when you need durable, replicated state

§ pluggable: Redis out-of-the-box, but feel free to bring your own

Page 19: Economies of Scaling Software

DEMO R E D I S - B A C K E D H T T P S E S S I O N S

Page 20: Economies of Scaling Software

PAAS: P L AT F O R M - A S - A - S E R V I C E

Page 21: Economies of Scaling Software

why PaaS?@Starbuxman @PolymathicCoder

Imagine if architects had to be the janitor for every building they designed. This is how the development team felt prior to moving to Windows Azure.

Duncan Mackenzie Nov 07, 2011 http://www.infoq.com/articles/Channel-9-Azure

“ ”

Page 22: Economies of Scaling Software

The Impact of the Cloud @Starbuxman @PolymathicCoder

§ Spring Boot makes it dead simple to stand up services.(Where do they live? Who runs them?)

§ Things get Distributed REALLY quickly! CF provides a way to simplify

!!

§ Manifests are are the ultimate installer. (cf push an entire distributed system!)

§ Spring Cloud PaaS connectors simplify service-consumption

> cf push hystrix.jar > cf push …

Page 23: Economies of Scaling Software

DEMO S I M P L E S C A L I N G O N T H E C L O U D

Page 24: Economies of Scaling Software

BUILDING ADAPTIVE APPLICATIONS IS HARD

built on Cloud Foundry !code will be open sourced.

Z - A X I S D ATA PA R T I T I O N I N G

Page 25: Economies of Scaling Software

CAP & N O S Q L

Page 26: Economies of Scaling Software

Brewer’s Conjecture (CAP)@Starbuxman @PolymathicCoder

Many datastores provide some of the following three characteristics: !!§ Consistency !§ Availability !§ Partitionability

!clarification #1: in a system with no network partitions (such as a single-node RDBMS), then there's no need to sacrifice C & A.!clarification #2: availability is a continuous value: 0-100%. there are many levels of consistency, and even partitions have nuances, including disagreement within the system about whether a partition exists.!

Page 27: Economies of Scaling Software

choose the best store for the job@Starbuxman @PolymathicCoder

Page 28: Economies of Scaling Software

NoSQL@Starbuxman @PolymathicCoder

Page 29: Economies of Scaling Software

S P R I N G D ATA R E P O S I T O R I E S

Page 30: Economies of Scaling Software

How it Works in Rails@Starbuxman @PolymathicCoder

class Car < ActiveRecordend

car = Car.new cars = car.find_cars_by_id(232) # where did this method come from?

# and then magic happens

Page 31: Economies of Scaling Software

Using Spring Data Repositories@Starbuxman @PolymathicCoder

•Spring Data Neo4J @EnableNeo4jRepositories •Spring Data JPA @EnableJpaRepositories •Spring Data MongoDB @EnableMongoRepositories •Spring Data GemFire @EnableGemfireRepositories

@Configuration @EnableTransactionManagement @ComponentScan @EnableJpaRepositories( basePackageClasses = BlogRepository.class) public class ServiceConfiguration { ! @Bean public DataSource dataSource(){ .. } @Bean public PlatformTransactionManager transactionManager(){ .. } }

Page 32: Economies of Scaling Software

Custom Repository @Starbuxman @PolymathicCoder

Keyword Sample Resulting MongoDB Query *

GreaterThan findByAgeGreaterThan(int age)

{"age" : {"$gt" : age}}LessThan findByAgeLessThan(int age) {"age" : {"$lt" : age}}Between findByAgeBetween(int from,

int to){"age" : {"$gt" : from, "$lt" : to}}NotNull findByFirstnameNotNull() {”firstname" : {"$ne" : null}}

Null findByFirstnameNull() {”firstname" : null}Like findByFirstnameLike(String

name)"firstname" : firstname} (regex)

Page 33: Economies of Scaling Software

M O N G O D B

Page 34: Economies of Scaling Software

Spring Data MongoDB@Starbuxman @PolymathicCoder

§ GridFS integration

§ GIS integration

§ Document mapping

Page 35: Economies of Scaling Software

who’s using MongoDB?@Starbuxman @PolymathicCoder

§ Mailbox.app: https://tech.dropbox.com/2013/09/scaling-mongodb-at-mailbox/

§ eHarmony: https://www.mongodb.com/presentations/big-dating-eharmony-0?_ga=1.259505294.567221685.1413121358

§ Expedia: https://www.mongodb.com/presentations/building-expedia%E2%80%99s-travel-graph-using-mongodb?_ga=1.26276665.567221685.1413121358

Page 36: Economies of Scaling Software

DEMO M O N G O D B G I S & FA C E B O O K P L A C E S

Page 37: Economies of Scaling Software

R E D I S

Page 38: Economies of Scaling Software

Spring Data Redis@Starbuxman @PolymathicCoder

§ key/value store

§ data structures § sets

§ queues

§ lists

§ maps

§ CacheManager implementation

§ memcached client

Page 39: Economies of Scaling Software

who’s using Redis?@Starbuxman @PolymathicCoder

§ Twitter: http://www.infoq.com/presentations/Real-Time-Delivery-Twitter

§ Sina Weibo http://www.xdata.me/?p=353

§ GitHub https://github.com/blog/530-how-we-made-github-fast

§ Snapchat https://twitter.com/robustcloud/status/448503100056535040

§ Pinterest http://engineering.pinterest.com/post/55272557617/building-a-follower-model-from-scratch

Page 40: Economies of Scaling Software

C O U C H B A S E

Page 41: Economies of Scaling Software

Spring Data Couchbase@Starbuxman @PolymathicCoder

§ keyed document access § sort of like a mix of Redis

and MongoDB

§ horizontally scalable

!@Configuration @EnableCouchbaseRepositories public class Application extends AbstractCouchbaseConfiguration { ! @Override protected List<String> bootstrapHosts() { return Arrays.asList( “127.0.0.1" ); } ! @Override protected String getBucketName() { return "default"; } ! @Override protected String getBucketPassword() { return ""; } !}

Page 42: Economies of Scaling Software

who’s using Couchbase?@Starbuxman @PolymathicCoder

§ AOL: http://www.couchbase.com/ad_platforms

§ Playtika: http://www.couchbase.com/social-gaming

Page 43: Economies of Scaling Software

N E O 4 J

Page 44: Economies of Scaling Software

complexity vs performance@Starbuxman @PolymathicCoder

Page 45: Economies of Scaling Software

who’s using Neo4j?@Starbuxman @PolymathicCoder

Page 46: Economies of Scaling Software

the evolution of searchPre-1999

WWW Indexing

Atomic Data

1999 - 2012 Google Invents

PageRank

Simple Connected Data

2012-? Google Launches the

Knowledge Graph

Rich Connected Data

@Starbuxman @PolymathicCoder

Page 47: Economies of Scaling Software

Recommenda)ons@Starbuxman @PolymathicCoder

Page 48: Economies of Scaling Software

Graph Search! @Starbuxman @PolymathicCoder

Page 49: Economies of Scaling Software

Graph Search! @Starbuxman @PolymathicCoder

Page 50: Economies of Scaling Software

What the Cypher Query Looks Like:@Starbuxman @PolymathicCoder

MATCH (person:Person)-[:IS_FRIEND_OF]->(friend), (friend)-[:LIKES]->(restaurant),

(restaurant)-[:LOCATED_IN]->(loc:Location), (restaurant)-[:SERVES]->(type:Cuisine) !WHERE person.name = 'Philip' AND loc.location='New York' AND type.cuisine='Sushi' !RETURN restaurant.name

* Cypher query language examplehttp://maxdemarzi.com/?s=facebook

Page 51: Economies of Scaling Software

What the Search Looks Like:@Starbuxman @PolymathicCoder

Page 52: Economies of Scaling Software

What the Search Looks Like:@Starbuxman @PolymathicCoder

Page 53: Economies of Scaling Software

DEMO N E O 4 J T W I T T E R

Page 54: Economies of Scaling Software

H A D O O P

Page 55: Economies of Scaling Software

spring for

Surviving the Big Data Wild-West with Spring for Hadoop

@Starbuxman @PolymathicCoder

Page 56: Economies of Scaling Software

S P R I N G X D

Page 57: Economies of Scaling Software

stream processing, data ingestion & integration

But How Do You Process Data Realtime?@metamarkets founder Michael E. Driscoll:

@Starbuxman @PolymathicCoder

Page 58: Economies of Scaling Software

stream processing, data ingestion & integration@Starbuxman @PolymathicCoder

Introducing Spring XD

sour

ces

sink

s

Page 59: Economies of Scaling Software

DEMO S P R I N G X D A N D P I V O TA L H D

Page 60: Economies of Scaling Software
Page 61: Economies of Scaling Software

BUILDING ADAPTIVE APPLICATIONS IS HARD

built on Cloud Foundry !code will be open sourced.

Y- A X I S B O U N D E D C O N T E X T S

Page 62: Economies of Scaling Software

micro- vs. monolith… is not a new discussion@Starbuxman @PolymathicCoder

From: [email protected] (Ken Thompson) Subject: Re: LINUX is obsolete Date: 3 Feb 92 23:07:54 GMT Organization: Georgia Institute of Technology I would generally agree that microkernels are probably the wave of the future. However, it is in my opinion easier to implement a monolithic kernel. It is also easier for it to turn into a mess in a hurry as it is modified. Regards, Ken

Page 63: Economies of Scaling Software

hold on a tick..

…didn’t the monolith win?

@Starbuxman @PolymathicCoder

Page 64: Economies of Scaling Software

so what’s so bad about a monolith?@Starbuxman @PolymathicCoder

(does your monolith drive you to drink?)

Page 65: Economies of Scaling Software

boardroom agility pushes tech agility@Starbuxman @PolymathicCoder

§ boardroom agility manifest in technology: • 2-pizza box teams are a result of eschewing organizational norms

!§ easier to scale (in development teams, and at runtime)

!§ shorter iterations: • small services >

continuous integration > shorter release cycles > deployment automation

Page 66: Economies of Scaling Software

the elegant microservice@Starbuxman @PolymathicCoder

Page 67: Economies of Scaling Software

problems with microservices@Starbuxman @PolymathicCoder

§ hard to deploy (devops!)

§ hard to tease into separate deployable modules (Boot!)

§ lots of moving parts introduces complexity (PaaS & Spring Cloud!)

Page 68: Economies of Scaling Software

W H Y B O O T

Page 69: Economies of Scaling Software

harder to tease into separate microservices? …No.@Starbuxman @PolymathicCoder

import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Configuration; import org.springframework.web.bind.annotation.* !// assumes org.springframework.boot:spring-boot-starter-web on CLASSPATH @Configuration @RestController @EnableAutoConfiguration public class GreetingsController { ! @RequestMapping("/hi/{name}") String hello(@PathVariable String name) { return "Hello, " + name + "!"; } ! public static void main(String[] args) { SpringApplication.run(GreetingsController.class, args); } }

Page 70: Economies of Scaling Software

managing many processes with a PaaS@Starbuxman @PolymathicCoder

§ services are explicit about what they bundle

§ services are attached resources (locally or remote, who cares)

§ configuration is external

§ scaling is easy

§ isolation is provided at the process level

Page 71: Economies of Scaling Software

emergent patterns of microservices@Starbuxman @PolymathicCoder

§ distributed / versioned configuration

§ service registration + discovery

§ client-side routing, service-to-service calls

§ load-balancing

§ minimizing failure cascades

§ proxies

Page 72: Economies of Scaling Software

Standing on the Shoulders of Spring &

@Starbuxman @PolymathicCoder

Page 73: Economies of Scaling Software

C O N F I G - S E R V E R

Page 74: Economies of Scaling Software

R E F R E S H - A B L E C O N F I G U R AT I O N

Page 75: Economies of Scaling Software

S E R V I C E R E G I S T R AT I O N & D I S C O V E R Y W I T H E U R E K A

http://techblog.netflix.com/2012/09/eureka.html

Page 76: Economies of Scaling Software

M A N A G I N G FA I L U R E S W I T H H Y S T R I X

http://techblog.netflix.com/2012/11/hystrix.html

Page 77: Economies of Scaling Software

D Y N A M I C R O U T I N G W I T H Z U U L

http://techblog.netflix.com/2012/11/hystrix.html

Page 78: Economies of Scaling Software

Bookmark..@Starbuxman @PolymathicCoder

§ The Netflix Techblog http://techblog.netflix.com

§ Fred Georges on Programmer Anarchy http://www.infoq.com/news/2012/02/programmer-anarchy

§ Matt Stine’s CF + Microservices: a Mutualistic Symbiotic Relationship http://www.youtube.com/watch?v=RGZefc92tZs

§ Martin Fowler’s article - http://martinfowler.com/articles/microservices.html

Page 79: Economies of Scaling Software

Bookmark..@Starbuxman @PolymathicCoder

§ Former Netflix DevOps Guru Adrian Cockroft on DevOps + MShttp://www.infoq.com/interviews/adrian-cockcroft-microservices-devops

§ Bootiful Applications with Spring Boothttp://http://www.youtube.com/watch?v=eCos5VTtZoI

§ Chris Richardson’s http://microservices.io site and his Decomposing Applications for Scalability talks

§ github.com/joshlong/scaling-software-talk

Page 80: Economies of Scaling Software

References spring.io/guides github.com/spring-cloud/ github.com/spring-cloud-samples/ github.com/joshlong/spring-doge github.com/joshlong/spring-doge-microservice docs.spring.io/spring-boot/ !

Questions?

Abdelmonaim Remani @PolymathicCoder

[email protected] github.com/PolymathicCoder

Josh Long @starbuxman

[email protected] github.com/joshlong

(⻰龙之春)