When the lift is broken, boost your EC2 based infrastructure
How to leverage on AWS to scale legacy PHP web applications to millions of page views per day without any modernization or replatforming: practical examples and real world projects (Wordpress, Drupal and Magento on AWS)
Papiniano 10 20123 Milano t +39 0431 65837 f +39 0431 668274 www.nohup.it [email protected] When the lift is broken, boost your EC2 based infrastructure
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 This diagram shows the percentages of websites using various server-side programming languages: PHP - 79.1% (46% still on PHP5)
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 This diagram shows the percentages of websites using various content management systems:
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 “A problem well stated is a problem half solved” Charles Kettering The first step to alleviating any problem is to clearly and accurately define what the problem actually is. For a web app this means finding out what resource your application is running out of on the servers; regarding the tier: 1. web application 2. database and the specific component: 1. Memory 2. CPU 3. Network I/O 4. Disk I/O
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 Amazon’s CloudWatch monitoring system is the easiest way to see most resource metrics for your EC2 instances and other AWS services You can enable detailed monitoring when available to increase that resolution to one minute. DISK IO: DiskReadOps/DiskWriteOps: This metric pair can help determine if degraded performance is the result of consistently high IOPS, causing bottlenecks as disk requests become queued. DiskReadBytes/DiskWriteBytes: Monitoring the amount of data being written to and read from disk can help reveal application-level problems. Too much data being read from disk might indicate that your application would benefit from adding a caching layer.
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 NETWORK IO: NetworkIn/NetworkOut: It’s unlikely that your instances will approach their network throughput limits unless they are severely mismatched with your application’s needs, but it can still be helpful to keep an eye on possible network saturation to make sure your instances meet demand. NetworkPacketsIn/NetworkPacketsOut: more important for security than for performance.
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 MEMORY: For many use cases, such as large, high-performance databases and in-memory applications, memory metrics are particularly vital to keeping an eye on your infrastructure and identifying problems and performance bottlenecks. However, Amazon’s CloudWatch does not report system-level memory metrics for instances. CPU: CPU Utilization: CPU usage is one of the prime host-level metrics to monitor. Depending on the application, consistently high utilization levels may be normal.
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 Hosting topology: never never never never make your domain address to a web server. Your domain should point to some sort of load balancer, which should then route requests between two or more web servers. Not only this setup makes it easy to survive failures, it also makes handling increased load easier as well. With a load balancer in front of two web servers, you can horizontally scale your application by bring up new web servers and putting them behind the load balancer.
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 ➢ Decouple web and database: use dedicated solutions for database. Decouple public website from private website: put admin, batch and cron workloads on dedicated servers. ➢ Add autoscaling to web servers layer. ➢ Use Redis/ElastiCache for sessions modifying php.ini configuration or enable sticky sessions on balancer. ➢ Leverage on S3 for static files or EFS to make it transparent. ➢ Cache Database Queries: enable caching on your database or check if your application supports an in memory database caching solution. ➢ Monitor your database for slow query and no index query.
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 ➢ Enable client side caching (cache control/expire headers). ➢ Add web caching layer (local or CDN): even if only for static files, it will lower the load on your servers. ➢ Use database replication if the application supports it. MySQL provides a nice mirror replication for databases. Oracle has its own Oracle plug for replication and AWS RDS provide up to five read replicas, which can span across the region and even the Amazon database Amazon Aurora can have 15 read replicas with Amazon Aurora autoscaling support. If a workload is highly variable, you should consider Amazon Aurora Serverless database to achieve high efficiency and reduced cost. ➢ If your application doesn’t support database replication, take a look at database proxies Note: Be careful with application caching: it could kill your database or your disk and make your performance worst. In case, try ramdisk for application caching directory.
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 ClioMakeUp è il blog e sito ecommerce della più grande community italiana dedicata alla Bellezza. L’esigenza L'infrastruttura ospitava su 2 server il software di gestione del blog. In seguito al successo del sito (anche grazie al programmi TV), ogni nuovo post o attività social causava alti picchi di utenti, con conseguenti problemi di performance. L'alto carico di lavoro causava dei periodi di downtime e una perdita sia in termini di utenti sia di introiti provenienti dalle campagne marketing (ADV). La soluzione implementata Facendo leva sui servizi gestiti forniti dalla piattaforma Cloud, l'infrastruttura è stata ridisegnata completamente gestendo nativamente autoscaling, distribuzione geografica ed alta affidabilità. Gli obiettivi raggiunti Anche a seguito di picchi di accesso massivi non si sono più verificati problemi di performance o periodi di downtime. La soluzione implementata ha portato ad un incremento del 5.000% nel numero di page views e del 2.500% nel numero dei visitatori.
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 Azienda italiana produttrice di automobili di lusso. L’esigenza L’infrastruttura doveva ospitare il nuovo sito e gli altri siti del gruppo, garantendo altissime performance di navigazione nonostante l’elevato peso delle pagine, ricche di contenuti multimediali ad alta risoluzione, e l’audience distribuita in tutto il mondo, incluse aree geografiche con reti potenzialmente problematiche (Russia, Cina, Emirati Arabi, ecc.). La soluzione implementata Facendo leva sui servizi gestiti forniti dalla piattaforma Cloud e sulla possibilità di distribuire i servizi su scala mondiale, l'infrastruttura è stata ridisegnata completamente gestendo nativamente autoscaling e alta affidabilità. Gli obiettivi raggiunti Nonostante il peso significativo delle pagine (20 MB di media per la home page) il lancio del sito sulla nuova infrastruttura si è rivelato un successo significativo in termini di performance e velocità, con un netto miglioramento in termini di affidabilità.
69/B 33058 San Giorgio di Nogaro (UD) [email protected] www.nohup.it Tel.: +39 0431 65837 Fax: +39 0431 668274 Damiani S.p.A. è una società italiana che opera nei settori di gioielleria e orologeria di lusso. L’esigenza Per i nuovi siti del Gruppo Damiani, le funzionalità editoriali e di ecommerce sono state consolidate in unico ambiente graficamente immersivo. Nasceva pertanto l’esigenza di rendere la componente ecommerce completamente integrata, flessibile e performante tanto nella parte consultiva (navigazione catalogo) che dispositiva (inserimento di items nel carrello). La soluzione implementata Per rendere i requisiti del cliente (Magento 2 e Wordpress) adeguati alle necessità tecniche, è stato effettuato un decoupling delle componenti server-side, sviluppando una frontend application con ReactJS in container ed un layer di API per l’interfacciamento con Magento e Wordpress. La componente frontend è stata inoltre distribuita geograficamente in base ai mercati di riferimento. Gli obiettivi raggiunti Estrema scalabilità e flessibilità del sistema, performance elevate, ottimizzazione dei costi.