Help! I need more servers! What do I do?

Similar documents
How to pimp high volume PHP websites. 27. September 2008, PHP conference Barcelona. By Jens Bierkandt

Scaling DreamFactory

Improve Web Application Performance with Zend Platform

Scalability of web applications

Chapter 6: Distributed Systems: The Web. Fall 2012 Sini Ruohomaa Slides joint work with Jussi Kangasharju et al.

Beginner's Guide to Performance! Jonathan Rowny

<Insert Picture Here> MySQL Web Reference Architectures Building Massively Scalable Web Infrastructure

Give Your Site a Boost With memcached. Ben Ramsey

High Availability High Performance Plone

Faster Programs = Happier Users. David McKinnis SureTech.com

DEPLOYMENT GUIDE Version 1.0. Deploying F5 with Apache Web Servers

Common Optimization Mistakes

Choosing a MySQL HA Solution Today. Choosing the best solution among a myriad of options

Inside Hatena Bookmark's Backend

Achieving Horizontal Scalability. Alain Houf Sales Engineer

SCALABLE WEB PROGRAMMING. CS193S - Jan Jannink - 2/02/10

CISC 7610 Lecture 2b The beginnings of NoSQL

MySQL HA Solutions. Keeping it simple, kinda! By: Chris Schneider MySQL Architect Ning.com

Jargons, Concepts, Scope and Systems. Key Value Stores, Document Stores, Extensible Record Stores. Overview of different scalable relational systems

Give Your Site a Boost With memcached. Ben Ramsey

CHAPTER 1: A REFRESHER ON WEB BROWSERS 3

Choosing a MySQL HA Solution Today

Real World Web Scalability. Ask Bjørn Hansen Develooper LLC

Deployment. Chris Wilson, AfNOG / 26

Oh yes, wpcache comes with a dashboard wpcache is not Plugin!

Building a Scalable Architecture for Web Apps - Part I (Lessons Directi)

An overview of Drupal infrastructure and plans for future growth. prepared by Kieran Lal for the Drupal Association

High Availability/ Clustering with Zend Platform

Large-Scale Web Applications

Extreme Computing. NoSQL.

MySQL Architecture Design Patterns for Performance, Scalability, and Availability

Bigtable. Presenter: Yijun Hou, Yixiao Peng

Designing, Scoping, and Configuring Scalable LAMP Infrastructure

Case Study. Performance Optimization & OMS Brainvire Infotech Pvt. Ltd Page 1 of 1

Optimizing LAMP Development with PHP5

Web Applications. Software Engineering 2017 Alessio Gambi - Saarland University

The Z-Files: Field reports from the world of business critical PHP applications

An Oracle White Paper April Deploying Web 2.0 Applications on Oracle Servers and the OpenSolaris Operating System

Real Life Web Development. Joseph Paul Cohen

<Insert Picture Here> MySQL Cluster What are we working on

Using MySQL for Distributed Database Architectures

HA solution with PXC-5.7 with ProxySQL. Ramesh Sivaraman Krunal Bauskar

More on Testing and Large Scale Web Apps

Introduction to Database Services

Scaling. Marty Weiner Grayskull, Eternia. Yashh Nelapati Gotham City

OS Mechanisms Posix c

MySQL HA Solutions Selecting the best approach to protect access to your data

Distributed Systems Principles and Paradigms. Chapter 12: Distributed Web-Based Systems

Scaling. Yashh Nelapati Gotham City. Marty Weiner Krypton. Friday, July 27, 12

How do we build TiDB. a Distributed, Consistent, Scalable, SQL Database

Distributed Data Infrastructures, Fall 2017, Chapter 2. Jussi Kangasharju

Cloud Based Application Architectures using Smart Computing

Scaling a Web Site. Lecture 14: Scale-out Parallelism, Elasticity, and Caching

Drupal Frontend Performance & Scalability

DEMYSTIFYING BIG DATA WITH RIAK USE CASES. Martin Schneider Basho Technologies!

INFRASTRUCTURE BEST PRACTICES FOR PERFORMANCE

Common Optimization Mistakes

High Availability Overview Paper

Owncloud scalability and a Nextcloud design for users.

Lessons learned while automating MySQL in the AWS cloud. Stephane Combaudon DB Engineer - Slice

Carrier grade VoIP systems with Kamailio

SQL, NoSQL, MongoDB. CSE-291 (Cloud Computing) Fall 2016 Gregory Kesden

Silicon House. Phone: / / / Enquiry: Visit:

Life as a Service. Scalability and Other Aspects. Dino Esposito JetBrains ARCHITECT, TRAINER AND CONSULTANT

Various MySQL High Availability (HA) Solutions

CISC 7610 Lecture 5 Distributed multimedia databases. Topics: Scaling up vs out Replication Partitioning CAP Theorem NoSQL NewSQL

Design Patterns for Large- Scale Data Management. Robert Hodges OSCON 2013

Infrastructure Tuning

MySQL Replication Options. Peter Zaitsev, CEO, Percona Moscow MySQL User Meetup Moscow,Russia

Scaling a Web Site. Lecture 14: Scale-out Parallelism, Elasticity, and Caching

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2017)

Distributed Architectures & Microservices. CS 475, Spring 2018 Concurrent & Distributed Systems

Deployment Guide AX Series with Oracle E-Business Suite 12

Hybride Cloud Szenarien HHochverfügbar mit KEMP Loadbalancern. Köln am 10.Oktober 2017

Part 12 殷亚凤. Homepage: Room 301, Building of Computer Science and Technology

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

Scaling Without Sharding. Baron Schwartz Percona Inc Surge 2010

How to Scale MongoDB. Apr

PostgreSQL clusters using streaming replication and pgpool-ii

CSE/EE 461 HTTP and the Web

A PAtCHy server: developed by the Apache group formed 2/95 around by a number of people who provided patch files for NCSA httpd 1.3 by Rob McCool.

Bigtable: A Distributed Storage System for Structured Data By Fay Chang, et al. OSDI Presented by Xiang Gao

Spotify. Scaling storage to million of users world wide. Jimmy Mårdell October 14, 2014

Wasser drauf, umrühren, fertig?

Scaling with Postgres. Robert Treat Percona Performance Conference 2009

CS November 2018

Scaling a Web Application. (mostly PHP/MySQL and almost mostly harmless) Duleepa Dups Wijayawardhana MySQL Community Team

CS November 2017

Etanova Enterprise Solutions

Performance, Scalability and High-availability of Enterprise Applications

Highly Available Database Architectures in AWS. Santa Clara, California April 23th 25th, 2018 Mike Benshoof, Technical Account Manager, Percona

ZENworks Mobile Workspace High Availability Environments. September 2017

What is Drupal? What is this Drew-Paul thing you do?

Aerospike Scales with Google Cloud Platform

Distributed Systems. 29. Distributed Caching Paul Krzyzanowski. Rutgers University. Fall 2014

HA for OpenStack: Connecting the dots

WHITE PAPER AGILOFT SCALABILITY AND REDUNDANCY

Building a Highly Scalable and Performant SMB Protocol Server

Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam, Netherlands October 3

MySQL Cluster Student Guide

Transcription:

Help! I need more servers! What do I do? Scaling a PHP application 1 2-Feb-09

Introduction A real world example The wonderful world of startups Who am I? 2 2-Feb-09

Presentation Overview - Scalability - Network infrastructure and components - Keeping server farms in sync - Static content delivery - Of databases and replications - Caching and code acceleration - Code planning, design and implementation techniques 3 2-Feb-09

Scalability Performance v/s high availability No right or wrong technique Having the right tools for the job 4 2-Feb-09

Load Balancers In the network 5 2-Feb-09

Load Balancers Software v/s hardware load balancers Software load balancer (eg: UltraMonkey) Hardware load balancer Pros Easy setup Flexible (more configuration options) Cheaper More robust Processes traffic at hardware level Tech agnostic: works with any OS Cons Most packages cannot handle large or complex networks Large amount of hardware More expensive 6 2-Feb-09

Session Persistence I m losing my sessions! 7 2-Feb-09

Session Persistence Sticky sessions Session sharing Database Session server Sharedance Session clustering in Zend Platform 8 2-Feb-09

Session Persistence 9 Overriding php s default session handler <?php function session_handler_open($save_path, $session_name) {... } function session_handler_close() {... } function session_handler_store($key, $data) {... } function session_handler_fetch($key) {... } function session_handler_delete($key) {... } function session_handler_gc($timeout) { } session_set_save_handler('session_handler_open', 'session_handler_close', 'session_handler_fetch', 'session_handler_store', 'session_handler_delete', 'session_handler_gc');?> 2-Feb-09

Server farms: Keeping servers in sync Code base Vendor tools PHP script using rsync #!/usr/local/php5/bin/php <?php $servers = array( '10.1.42.11', //web2 '10.1.42.12', //web3 '10.1.42.13', //web4 '10.1.42.14', //web5 '10.1.42.15', //web6 '10.1.42.16', //web7 '10.1.42.17', //web8 ); foreach($servers as $server) { //rsync /www/doc_root $command = "rsync -avz /www/doc_root/ $server:/www/doc_root"; echo "Syncing /www/doc_root on $server...\n"; echo "------------------\n"; echo shell_exec($command). "\n";?> 10 2-Feb-09

Server farms: Keeping servers in sync Server configurations Need to restart servers after config changes Apache configs PHP configs Zend platform synchronises php.ini files across servers and restarts them 11 2-Feb-09

Static content separation Why separate static content? Memory consumption Blocking Apache processes for large files How to separate static content? Types of static content: js, css, images, videos, audio, html Changing application s urls for static content Using a low memory footprint server to serve static content (lighttpd, thttpd ) Zend platform s download server Content delivery network (CDN) 12 2-Feb-09

Static content separation Typical prefork MPM Apache config <IfModule mpm_prefork_module> ServerLimit 1024 StartServers 128 MinSpareServers 256 MaxSpareServers 512 MaxClients 1024 MaxRequestsPerChild 2000 </IfModule> 13 2-Feb-09

Static content separation Comparing the different content separation ways Pros Cons Zend Download server Easy integration Still the same server Static content server Total content separation Optimal resources utilization Harder to integrate Extra set of servers to maintain Content Delivery Network Speed! Harder to integrate (change all links) Cost 14 2-Feb-09

Lighttpd benchmark Concurrency Level: 10,000 Time taken for tests: 5.420 seconds Complete requests: 100,000 Failed requests: 0 Write errors: 0 Keep-Alive requests: 0 Total transferred: 419,968,990 bytes HTML transferred: 388,510,351 bytes Requests per second: 18,449.53 [#/sec] (mean) Time per request: 542.019 [ms] (mean) Time per request: 0.054 [ms] (mean, across all concurrent requests) Transfer rate: 75,666.30 [Kbytes/sec] received 15 2-Feb-09

Application database infrastructure High performance and high availability for MySQL Master-slave replication Dual master replication DRBD + Heartbeat MySQL Cluster Vertical and horizontal partitioning Shards 16 2-Feb-09

Application database infrastructure How does all this affect your code? Some technologies implement scalability transparently Replication, to take advantage of it for performance, requires separation of read/write queries One way to do that would be to implement a wrapper with methods: mysql_safe_reader(), mysql_safe_writer() MySQL proxy 17 2-Feb-09

Application database infrastructure Some tools to optimize MySQL s performance General query log with mysql_sla Mysql slow query log (log_slow_queries) Monyog 18 2-Feb-09

Application database infrastructure Comparison of MySQL scalability options Pros Cons Master-slave replication Easy setup No automatic failover Need to recode application Dual Master replication No app changes required High throughput Need a load balancer If data falls out of sync, DRBD MySQL cluster No app changes required Fast failover Extremely high throughput True redundancy No app changes required recovery very hard Two servers max Always one inactive server Complex setup Big amounts of RAM required on servers Lots of servers required 19 2-Feb-09

Application database infrastructure More details in MySQL manual, chapter 14, high availability and scalability 20 2-Feb-09

Code acceleration How code accelerators work Xcache, APC, eaccelerator Zend platform Code accelerator 21 2-Feb-09

Code acceleration How code accelerators work Xcache, APC, eaccelerator Zend platform Code accelerator 22 2-Feb-09

Caching Database requests caching Usually the primary bottleneck Limit the number of requests to the db Use memcahed for frequently accessed data that does not change often HTML caching At application level, generate HTML pages that do not change often, and serve them as HTML Zend Platform caching 23 2-Feb-09

Caching Database requests caching Usually the primary bottleneck Limit the number of requests to the db Use memcahed for frequently accessed data that does not change often 24 2-Feb-09

Caching Memcache example $memcache = new Memcache(); $memcache->connect('yourserverhost', 11211) or die("could not connect to memcache server"); function gettopfiles() { global $memcache; $query = "SELECT TOP 100 id, filename, rank FROM files ORDER BY rank DESC"; $querymd5 = md5($query); //Connect to memcache server $results = $memcache->get($querymd5); if(!$results) { $results = mysql_safe_reader($query); //store for a day. 0: do not compress $memcache->set($querymd5, $results, 0, 86400); } return $results; } 25 2-Feb-09

Caching HTML caching At application level, generate HTML pages that do not change often, and serve them as HTML Zend Platform caching 26 2-Feb-09

Caching Zend Platform caching screenshot 27 2-Feb-09

Caching Client side caching Expired header Etag 28 2-Feb-09

PHP Code design considerations Zend Framework What is Zend Framework? How can it help me in my development? 29 2-Feb-09

PHP Code design considerations How is the application split? Modular design advantages Segmentation across multiple servers Shared storage Data centralization 30 2-Feb-09

Conclusion Plan, plan then plan some more Ensure compatibility 31 2-Feb-09

Thank you! Maurice Kherlakian Email: maurice.kherlakian@bell.ca Skype: mkherlakian 32 2-Feb-09