Evolution of Web Application Architecture · Evolution of Web Application Architecture...

34
Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn / <[email protected]> June 9th, 2015

Transcript of Evolution of Web Application Architecture · Evolution of Web Application Architecture...

Page 1: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution of Web Application ArchitectureInternational PHP Conference

Kore Nordmann / @koredn / <[email protected]>June 9th, 2015

Page 2: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 3: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Problem

Too many visitors

Page 4: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 5: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 6: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Lessons Learned: Load Balancing

I Works because of HTTP & PHPI HTTP is LCoDC$SSI PHP is build for shared-nothing

I Round Robin works bestI Sticky sessions will overload certain servers

Page 7: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Problem

Non-sticky session – how?

Page 8: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 9: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Problem

Where to put the static data?

Page 10: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 11: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Lessons Learned: Static Files

I NFS will eventually lead to dead locksI . . . still seems the most popular solution around.

I Multiple domains can hurt performance (TCP slow start)I Using dedicated CDN providers can help

I Content locality

Page 12: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Problem

DB server too slow

Page 13: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 14: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Lessons Learned: Replicate Database

I Master Slave Replication is fairly easy to set upI Obviously only scales READsI WRITEs are usually not your first problem

Page 15: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Problem

DB servers are too expensive

Page 16: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 17: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Lessons Learned: Cache With Memcache

I Cache all the things in memoryI Cache entitiesI Cache collectionsI Full page cache

I Cache invalidationThere are three hard things in Computer Science:Cache invalidation and off by one errors.

I Cache dependency calculationI The n + 1 problem

Page 18: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Problem

Too many writes

Page 19: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 20: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Lessons Learned: Sharding

I Shard by tableI . . . or even shard by consistent hash per entityI No referential integrity checking

I Queries are limited to sharding solutionI Schema updates across multiple shards are fun

Page 21: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Problem

Database setup too complex

Page 22: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 23: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Lessons Learned: NoSQL

I Usually solves one problem really well:I ShardingI Multi-Master-ReplicationI Cross-shard queries

I . . . we lost all relevant features from Relational DatabaseManagement Systems anyways. . .

Page 24: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Problem

Business wants to query data

Page 25: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 26: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Lessons Learned: Map-Reduce

I Execute queries on distributed databasesI New query language to learn

I Your developers write analysis scripts, instead of the businessanalysts writing SQL slow queries

Page 27: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Problem

How to orchestrate?

Page 28: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 29: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Lessons Learned: Queues

I Queues can ensure data is processed asynchronouslyI Following the data flow of an action can be “tricky”

I Used to distribute data between systems

Page 30: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Evolution

Page 31: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Microservices

I Microservices can simplify things:I Separate services by concern or teamI Decide on technology stack per service

I Microservices will also complicate things:I Deployment automation is a mustI Service orchestration is still a problemI Service downtimes and latency must be handled gracefully

I Big DataTM will stay a problem

Page 32: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Lessons Learned (subjective)

I Boring technology choices will often work bestI Just start & stay with LAMP?

I Only bring in shiny new technologies with careI There are enough reasons to eventually do that, though

Page 33: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015

Copyright Qafoo GmbH; All Rights Reservedtalks.qafoo.com

Conclusion

There is no conclusion

Do not jump on every bandwagon – this includesmicroservices

Page 34: Evolution of Web Application Architecture · Evolution of Web Application Architecture International PHP Conference Kore Nordmann / @koredn /  June 9th, 2015