Performance. CSC309 TA: Sukwon Oh



Similar documents
Drupal Performance Tuning

Varnish the Drupal way

IERG 4080 Building Scalable Internet-based Services

ICON UK 2015 node.js for Domino developers. Presenter: Matt White Company: LDC Via

Demystifying cache. Kristian Lyngstøl Product Specialist Varnish Software AS

PROFESSIONAL. Node.js BUILDING JAVASCRIPT-BASED SCALABLE SOFTWARE. Pedro Teixeira WILEY. John Wiley & Sons, Inc.

Cache All The Things

Large-Scale Web Applications

Monitor Your Home With the Raspberry Pi B+

STeP-IN SUMMIT June 2014 at Bangalore, Hyderabad, Pune - INDIA. Mobile Performance Testing

eccharts: Behind the scenes

Speed up your web site. Alan Seiden Consulting alanseiden.com

Nginx 1 Web Server Implementation

Platform Architecture & Integration with OpenShift

making drupal run fast

Varnish Tips & Tricks, 2015 edition

Realtime

Intel IT s Cloud Journey. Speaker: [speaker name], Intel IT

Lecture 8a: WWW Proxy Servers and Cookies

Open Source Technologies on Microsoft Azure

FIVE WAYS TO OPTIMIZE MOBILE WEBSITE PERFORMANCE WITH PAGE SPEED

Front-End Performance Testing and Optimization

How To Optimize Your Website With Radware Fastview

1. Comments on reviews a. Need to avoid just summarizing web page asks you for:

The best reverse proxy around. Kristian Lyngstøl PRODUCTS CONSULTING APPLICATION MANAGEMENT IT OPERATIONS SUPPORT TRAINING

(An) Optimal Drupal 7 Module Configuration for Site Performance JOE PRICE

Accelerating Wordpress for Pagerank and Profit

Responsive, resilient, elastic and message driven system

Web Performance. Lab. Bases de Dados e Aplicações Web MIEIC, FEUP 2014/15. Sérgio Nunes

JAVA IN THE CLOUD PAAS PLATFORM IN COMPARISON

E-commerce is also about

Mobile Performance Testing Approaches and Challenges

The importance of Drupal Cache. Luis F. Ribeiro Ci&T Inc. 2013

9 Tried and Tested Tips to Increase the Power of your Magento Store

Tipping The Scale Tips, Tools, and Techniques For Building Scalable. Steve French Senior Software Engineer digg.com

opalang - Rapid & Secure Web Development

OpenShift on you own cloud. Troy Dawson OpenShift Engineer, Red Hat November 1, 2013

Web Performance. Sergey Chernyshev. March '09 New York Web Standards Meetup. New York, NY. March 19 th, 2009

WordPress Optimization

Peer-to-peer web hosting software: specification and source code update

CMS Diagnostics Guide

CS312 Solutions #6. March 13, 2015

socketio Documentation

A GUIDE TO PHONE-BASED PASSWORD PROTECTION (SAMPLE CODE INCLUDED)

Performance Optimization For Operational Risk Management Application On Azure Platform

Website Performance: Kyle Simpson

ios App Performance Things to Take Care

The Devil is in the Details. How to Optimize Magento Hosting to Increase Online Sales

What about MongoDB? can req.body.input 0; var date = new Date(); do {curdate = new Date();} while(curdate-date<10000)

Improving Magento Front-End Performance

CT30A9301 Code Camp on Platform Based Application Development. LocalEAT

Performance Testing Process A Whitepaper

79 Tips and Tricks for Magento Performance Improvement. for Magento Performance Improvement

Web Applications: Overview and Architecture

APACHE WEB SERVER. Andri Mirzal, PhD N

Brace for 2012 Christoph

NoSQL replacement for SQLite (for Beatstream) Antti-Jussi Kovalainen Seminar OHJ-1860: NoSQL databases

Cluster Computing. ! Fault tolerance. ! Stateless. ! Throughput. ! Stateful. ! Response time. Architectures. Stateless vs. Stateful.

Q: What is the difference between the other load testing tools which enables the wan emulation, location based load testing and Gomez load testing?

DotSlash: Providing Dynamic Scalability to Web Applications with On-demand Distributed Query Result Caching

PeopleSoft Online Performance Guidelines

Practical Load Balancing

Beginning Web Development with Node.js

Removing Failure Points and Increasing Scalability for the Engine that Drives webmd.com

Avaya Inventory Management System

What is a CMS? Why Node.js? Joel Barna. Professor Mike Gildersleeve IT /28/14. Content Management Systems: Comparison of Tools

Using Steelhead Appliances and Stingray Aptimizer to Accelerate Microsoft SharePoint WHITE PAPER

ZingMe Practice For Building Scalable PHP Website. By Chau Nguyen Nhat Thanh ZingMe Technical Manager Web Technical - VNG

Lecture 3: Scaling by Load Balancing 1. Comments on reviews i. 2. Topic 1: Scalability a. QUESTION: What are problems? i. These papers look at

StriderCD Book. Release 1.4. Niall O Higgins

Online Fuzzy-C-Means clustering

Super Pro Net TM Network Key Installation and Operation

Building A Self-Hosted WebRTC Project

EWD: Simplifying Web Application Architecture

4x High Performance for Drupal. Presented by Fabian Franz. Step by Step

Architecture Workshop

Web [Application] Frameworks

Ehcache Web Cache User Guide. Version 2.9

Cloud Operating Systems for Servers

TESTING AND OPTIMIZING WEB APPLICATION S PERFORMANCE AQA CASE STUDY

A Tool for Evaluation and Optimization of Web Application Performance

A 100k Users.. Now What?

Web application Architecture

Web Development with Flask and the Raspberry Pi Leading by Example CUAUHTEMOC CARBAJAL ITESM CEM 22/04/2014

An Esri White Paper January 2010 Performance and Throughput Tips for ArcGIS Server Cached Map Services and the Apache HTTP Server

A Baseline for Web Performance

Application Performance Testing Basics

Layers of Caching: Key to scaling your website. Lance Albertson -- Narayan Newton

Testing & Assuring Mobile End User Experience Before Production. Neotys

Content Management System

PERFORMANCE TESTING CRASH COURSE

Liferay Performance Tuning

Spark Application Carousel. Spark Summit East 2015

MEAN/Full Stack Web Development - Training Course Package

ORACLE COHERENCE 12CR2

Linux A first-class citizen in Windows Azure. Bruno Terkaly bterkaly@microsoft.com Principal Software Engineer Mobile/Cloud/Startup/Enterprise

Server-Side JavaScript auf der JVM. Peter Doschkinow Senior Java Architect

Performance Testing Crash Course

Internet Content Distribution

Web Performance First Aid. Alan Seiden Consulting alanseiden.com

Transcription:

Performance CSC309 TA: Sukwon Oh

Outline 1. Load Testing 2. Frontend Tips 3. Server-side Tips

Load Testing Load testing is the process of putting demand on a system or device and measuring its response. Load testing is performed to determine a system's behavior under both normal and anticipated peak load conditions.

Load Testing in High Level Purpose Predict how your application will perform when a large number of users are using your application at the same time How? Simulate artificial but realistic workloads

Load Testing Tools JMeter Free and written in Java Tsung Free and written in Erlang loader.io Partially free; integrates with Heroku locust.io Free and written in Python (Today s Focus)

locust.io Advantages Write simple Python code to simulate a user behaviour Handles thousands of users on a single machine Disadvantages Results are downloadable in CSV format

locust.io Installation pip install locustio

locust.io Every HTTP connection will open a new file, but OS sets a limit for the max # of files that can be opened. You need: # max open files >= # of user you want to test Linux ulimit -Sn <# max open files> <- works up to ~64,000 Make sure to do this for both terminals running express.js and locust.io!!!

locust.io 1. Simulating a user Write a class subclassing HttpLocust to define a user.

Example class User(HttpLocust): task_set = UserTasks min_wait = 5000 max_wait = 15000 Explanation: A user s behaviour will be defined in UserTasks class. The user will wait randomly between 5 to 15 secs before sending a request to the application.

Example class UserTasks(TaskSet): @task(2) def index(self): self.client.get( / ) @task(1) def about(self): self.client.get( /about/ ) Explanation: A user will randomly send a GET request to / endpoint and a GET request to /about/ endpoint. The user will send GET requests to / about twice as many times as GET requests to /about/.

locust.io Web Interface

locust.io Web Interface

Demo

Front-end Tips 1. gzip 2. cache control

gzip in express.js Use compress middleware (Version 3.x) app.use(express.compress()); Use compression middleware (Version 4.x) var compress = require( compression ); app.use(compress());

Cache Control HTTP Header You can tell a user s browser to cache specific resources from your application e.g. images, js files, css files, etc Reduce latency a user will receive response faster Reduce network bandwidth a network can handle more messages

Cache Control Useful headers max-age=[seconds] max amount of time a resource will be considered fresh no-cache forces server validation before releasing a cached copy no-store disable caching a resource public/private allow/disable caching a response to a public (shared) cache

Cache Control What happens if a resource seems stale? Cache will try to validate its copy against your application Uses Last-Modified or ETags header

Last-Modified How it works

ETags How it works ETag usually computes a hash of a resource to detect any changes made to it.

Cache Control in express.js Good News! They are mostly built-in or easy to use!

Cache Control in express.js Static Files Use express.static() with maxage option Example app.use(express.static( dirname + /public, { maxage: 86400000 }));

Cache Control in express.js favicon serve-favicon module Example var favicon = require( serve-favicon ); app.use(favicon(path.join( dirname, public, favicon.ico ), {maxage: 86400000}));

Cache Control in express.js ETags express.js calculates ETags automatically However, if you want to customize it app.set( etag, function(body, encoding) { }); return calculatehash(body, encoding);

Cache Control in express.js response.send() does automatic cache control support http://expressjs.com/api.html for more information But you can always set these headers manually!

Backend Tips 1. Increase parallelism of node.js 2. Caching 3. DB index

Node.js Asynchronous + single threaded Almost all computers are multi-core now node.js (express.js) uses only 1 core by default! Solution? Run one node.js process per core of your machine

Cluster module cluster module makes your job of managing multiple node.js processes easier. https://nodejs.org/api/cluster.html for more information

Cluster module var cluster = require( cluster ); var numcpus = require( os ).cpus().length; if (cluster.ismaster) { for (var i = 0; i < numcpus; i++) cluster.fork(); } else { var app = require( express )(); app.get( /, function(req, res) {..}); app.listen(3000); }

Handling failures if (cluster.ismaster) { for (var i = 0; i < numcpus; i++) cluster.fork(); cluster.on( exit, function(worker) { cluster.fork(); }); }

Caching Basic Idea: Cache resources that are costly to generate and frequently read and rarely modified Options: Redis, Memcached, Varnish,...

Caching with Redis Key-value cache/store known to be very very fast! http://redis.io/ Idea: Store results from expensive computation in Redis for quick reuse (avoid computation)

Using Redis Installation instruction in http://redis. io/download Provides node.js driver similar to MongoDB npm install redis

Example app.get( /expensive, function(req, res) { var result = 0; for(var i = 0; i < 100000; i++) {..} res.send(result); });

Example var redis = require( redis ); var client = redis.createclient(); app.get( /expensive, function(req, res) { client.get( result, function(err, val) { if (val) return res.send(val); else { var result = 0; for(var i=0; i<10000; i++) {..} client.set( result, result); } }); });

MongoDB Index Lets you avoid scanning every document in a collection Speeds up your read operations However, they may hurt your write operations Because it needs to write more data

MongoDB Index Indexes are just data structures that stores specific field values in sorted order Example db.collection( collection ).createindex( ); {field: 1}