22-Aug-15 | 1 |1 | Help! I need more servers! What do I do? Scaling a PHP application.

Slides:



Advertisements
Similar presentations
From Startup to Enterprise A Story of MySQL Evolution Vidur Apparao, CTO Stephen OSullivan, Manager of Data and Grid Technologies April 2009.
Advertisements

Database Architectures and the Web
Amazon RDS (MySQL and Oracle) and SQL Azure Emil Tabakov Telerik Software Academy academy.telerik.com.
Adding scalability to legacy PHP web applications Overview Mario A. Valdez-Ramirez.
Approaches to EJB Replication. Overview J2EE architecture –EJB, components, services Replication –Clustering, container, application Conclusions –Advantages.
CSE 190: Internet E-Commerce Lecture 16: Performance.
Creating WordPress Websites. Creating a site on your computer Local server Local WordPress installation Setting Up Dreamweaver.
Multiple Tiers in Action
Analysis and Performance Information Systems 337 Prof. Harry Plantinga.
Nikolay Tomitov Technical Trainer SoftAcad.bg.  What are Amazon Web services (AWS) ?  What’s cool when developing with AWS ?  Architecture of AWS 
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications C. Faloutsos – A. Pavlo How to Scale a Database System.
Microsoft Load Balancing and Clustering. Outline Introduction Load balancing Clustering.
Capacity Planning in SharePoint Capacity Planning Process of evaluating a technology … Deciding … Hardware … Variety of Ways Different Services.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
Distributed Data Stores – Facebook Presented by Ben Gooding University of Arkansas – April 21, 2015.
Cloud Computing for the Enterprise November 18th, This work is licensed under a Creative Commons.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Training Workshop Windows Azure Platform. Presentation Outline (hidden slide): Technical Level: 200 Intended Audience: Developers Objectives (what do.
Application Layer CHAPTER 2. Announcements and Outline  Administrative Items  Questions? Recap 1.Introduction to Networks 1.Network Type 2.N etwork.
#devshark welcome to #devshark. #devshark HELLO! I’M Ville Rauma Fingersoft Product Owner Web
APACHE 2.0 A Look Under the Hood CHUUG, June 2002 by Cliff Woolley
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
Performance Concepts Mark A. Magumba. Introduction Research done on 1058 correspondents in 2006 found that 75% OF them would not return to a website that.
Web Services CSCI N321 – System and Network Administration Copyright © 2007,2008 by Scott Orr and the Trustees of Indiana University.
Presented by CH.Anusha.  Apache Hadoop framework  HDFS and MapReduce  Hadoop distributed file system  JobTracker and TaskTracker  Apache Hadoop NextGen.
Victor Mushkatin, MCSE, MCSD CORPORATION Alexander Zakonov, MCSE, MCSD Stephen Pelletier, MCSE.
Unit – I CLIENT / SERVER ARCHITECTURE. Unit Structure  Evolution of Client/Server Architecture  Client/Server Model  Characteristics of Client/Server.
CSC 2720 Building Web Applications Improving Web Application Performance.
Scalable Web Server on Heterogeneous Cluster CHEN Ge.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
BW Know-How Call : Performance Tuning dial-in phone numbers! U.S. Toll-free: (877) International: (612) Passcode: “BW”
Chapter 6 Server-side Programming: Java Servlets
Designing a Scalable Enterprise Project Management Architecture Ken Toole Platform Test Manager MS Project Microsoft Corporation.
Kiew-Hong Chua a.k.a Francis Computer Network Presentation 12/5/00.
® IBM Software Group © 2007 IBM Corporation Best Practices for Session Management
Server to Server Communication Redis as an enabler Orion Free
INTRODUCTION TO WEB APPLICATION Chapter 1. In this chapter, you will learn about:  The evolution of the Internet  The beginning of the World Wide Web,
1 Session 1: Introduction to PHP & MySQL iNET Academy Open Source Web Development.
PHP Performance w/APC + thaicyberpoint.com thaithinkpad.com thaihi5.com.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Infrastructure for Data Warehouses. Basics Of Data Access Data Store Machine Memory Buffer Memory Cache Data Store Buffer Bus Structure.
Accelerating PHP Applications Ilia Alshanetsky O’Reilly Open Source Convention August 3rd, 2005.
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Scalable Data Scale #2 site on the Internet (time on site) >200 billion monthly page views Over 1 million developers in 180 countries.
09/13/04 CDA 6506 Network Architecture and Client/Server Computing Peer-to-Peer Computing and Content Distribution Networks by Zornitza Genova Prodanoff.
Performance & Security Satish C Ayappan (Drupal Architect- Capgemini)
Web Cache. What is Cache? Cache is the storing of data temporarily to improve performance. Cache exist in a variety of areas such as your CPU, Hard Disk.
Cofax Scalability Document Version Scaling Cofax in General The scalability of Cofax is directly related to the system software, hardware and network.
Fault – Tolerant Distributed Multimedia Streaming Web Application By Nirvan Sagar – Srishti Ganjoo – Syed Shahbaaz Safir
Practical Hadoop: do’s and don’ts by example Kacper Surdy, Zbigniew Baranowski.
Wikimedia architecture Ryan Lane Wikimedia Foundation Inc.
Lecture 18: Scalable Web Services
Improving searches through community clustering of information
Web Development Web Servers.
Introduction to PHP FdSc Module 109 Server side scripting and
Time is the enemy: Ten Core Lessons for Achieving Peak
Platform as a Service.
1. Public Network - Each Rackspace Cloud Server has two networks
CHAPTER 2 Application Layer.
PHP / MySQL Introduction
Utilization of Azure CDN for the large file distribution
Architecture of Large-Scale Websites
Scaling and Performance
Edge computing (1) Content Distribution Networks
Introduction to Apache
Client-Server Model: Requesting a Web Page
Client/Server Computing and Web Technologies
Yale Digital Conference 2019
Web Application Development Using PHP
Presentation transcript:

22-Aug-15 | 1 |1 | Help! I need more servers! What do I do? Scaling a PHP application

22-Aug-15 | 2 |2 | A real world example The wonderful world of startups Who am I? Introduction

22-Aug-15 | 3 |3 | -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 Presentation Overview

22-Aug-15 | 4 |4 | Performance v/s high availability No right or wrong technique Having the right tools for the job Scalability

22-Aug-15 | 5 |5 | In the network Load Balancers

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

22-Aug-15 | 7 |7 | I’m losing my sessions! Session Persistence

22-Aug-15 | 8 |8 | Sticky sessions Session sharing –Database –Session server Sharedance Session clustering in Zend Platform Session Persistence

22-Aug-15 | 9 |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'); ?> Session Persistence

22-Aug-15 | 10 | Code base Vendor tools PHP script using rsync #!/usr/local/php5/bin/php <?php $servers = array( ' ', //web2 ' ', //web3 ' ', //web4 ' ', //web5 ' ', //web6 ' ', //web7 ' ', //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"; ?> Server farms: Keeping servers in sync

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

22-Aug-15 | 12 | 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) Static content separation

22-Aug-15 | 13 | Typical prefork MPM Apache config ServerLimit 1024 StartServers 128 MinSpareServers 256 MaxSpareServers 512 MaxClients 1024 MaxRequestsPerChild 2000 Static content separation

22-Aug-15 | 14 | Comparing the different content separation ways Static content separation

22-Aug-15 | 15 | Concurrency Level: 10,000 Time taken for tests: 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, [#/sec] (mean) Time per request: [ms] (mean) Time per request: [ms] (mean, across all concurrent requests) Transfer rate: 75, [Kbytes/sec] received Lighttpd benchmark

22-Aug-15 | 16 | High performance and high availability for MySQL Master-slave replication Dual master replication DRBD + Heartbeat MySQL Cluster Vertical and horizontal partitioning Shards Application database infrastructure

22-Aug-15 | 17 | 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

22-Aug-15 | 18 | Some tools to optimize MySQL’s performance General query log with mysql_sla Mysql slow query log (log_slow_queries) Monyog Application database infrastructure

22-Aug-15 | 19 | Application database infrastructure Comparison of MySQL scalability options

22-Aug-15 | 20 | Application database infrastructure More details in MySQL manual, chapter 14, high availability and scalability

22-Aug-15 | 21 | Code acceleration How code accelerators work Xcache, APC, eaccelerator Zend platform Code accelerator

22-Aug-15 | 22 | Code acceleration How code accelerators work Xcache, APC, eaccelerator Zend platform Code accelerator

22-Aug-15 | 23 | 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 Caching

22-Aug-15 | 24 | 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 Caching

22-Aug-15 | 25 | 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; } Caching

22-Aug-15 | 26 | HTML caching –At application level, generate HTML pages that do not change often, and serve them as HTML Zend Platform caching Caching

22-Aug-15 | 27 | Caching Zend Platform caching screenshot

22-Aug-15 | 28 | Caching Client side caching –Expired header –Etag

22-Aug-15 | 29 | PHP Code design considerations Zend Framework –What is Zend Framework? –How can it help me in my development?

22-Aug-15 | 30 | PHP Code design considerations How is the application split? –Modular design advantages –Segmentation across multiple servers Shared storage –Data centralization

22-Aug-15 | 31 | Conclusion Plan, plan then plan some more Ensure compatibility

22-Aug-15 | 32 | Thank you! Maurice Kherlakian Skype: mkherlakian