SlideShare a Scribd company logo
1 of 73
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Scalability &
Performance
Principles & Techniques
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
What is a Performance Problem?
System is Slow
for a Single User
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
What is a Scalability Problem?
Fast for Single User
but
Slow under Heavy
Load
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
How do you measure Performance?
Response Time for 1 User
i.e. how long the user waits
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Number of Users that
can work simultaneously
with acceptable performance
How do you measure Scalability?
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
95% of
time is
spent in
fronten
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
But, we won’t talk about
frontend performance
improvements today.
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Let’s
talk
about
backend
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Relationship between Performance & Scalability
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Performance & Scalability Mantra
Strive for maximum throughput with
acceptable response times
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
To Improve Scalability...
Improve
Performance
Add
Capacity
OR
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Response Time : 1s
Workers : 4
Machines : 1
Poor Performance & Scalability
4 requests/second
Slowest response : 1s
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Better Performance & Scalability
Response Time :
500ms
Workers : 4
Machines : 1
8 requests/second
Slowest response : 1s
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Even Better Performance ...
Response Time :
100ms
Workers : 4
Machines : 1
40 requests/second
Slowest response : 1s
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Great Performance & Scalability
Response Time : 10ms
Workers : 4
Machines : 1
400 requests/second
Slowest response : 1s
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
You cannot make response time 0ms
To support more than
400 requests….
Increase
Number of
Workers
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
With double the workers...
Response Time : 10ms
Workers : 8
Machines : 2
800 requests/second
Slowest response : 1s
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
and with even more workers...
Response Time : 10ms
Workers : 16
Machines : 4
1600 requests/second
Slowest response : 1s
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Coming Back To Reality
Increasing
Capacity Should
Increase
Throughput
It Does
Not.
Not Until You
Design Your
Application
Correctly.
Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
You have to
increase capacity at
each layer.
Web & App Server
Cache Server, Database
CPU, Network, Disk
Why?
And there are
locks.
Database Locks
Synchronized Code Blocks.
Mutexes
File System Locks
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
What should our goal be?
1. Reduce Response Times
2. Make it possible to add
more Capacity
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Scaling Data Storage
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Browser
Edge
Server
Load
Balancer
Web
Server
App Server REST API DatabaseUser
Browser
Edge
Server
Load
Balancer
Web
Server
App Server REST API DatabaseUser
Browser
Cache
CDN
Web
Accelerator
Nginx /
Apache
Object
Cache
Akamai
AWS Cloudfront
VarnishAll Browsers
All Mobiles
mod_proxy Static Variables
Redis, Memcached
EHCache
Less Granularity, More Effective More Granularity, Less Effective
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
HTTP Caching Strategy
Cache Forever
Cache-Control : maxage
Expires :
Do Not Cache
Cache-Control : maxage=-1
Expires : 1970-01-01
Cache Temporarily
Cache-Control : maxage=3600
Expires : <now plus 1 hour>
➔ Use for HTML pages with dynamic content
➔ Avoid for static resources
➔ Use for high traffic public html pages - i.e. homepage
➔ Specify etag or expires header to use conditional GET
➔ Use javascript to load user specific data
➔ Avoid for static resources
➔ Use for static resources - css, images, js
➔ Change URL in HTML when resource is modified
➔ Use a pre-processor to simplify management
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Cache Temporarily
Render this using JS
after page load
Cache for 2h.
Don’t overdo. You
cannot change the URL
of your homepage if the
content has to change.
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Cache Static Files Permanently
Static files are loaded
from browser cache
Cache Forever
If base.css changes, serve it
from base.css?v=2
New URL. Fresh Download.
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Cache-Control: private
Logged in user-
specific pages or APIs.
Only Cached By
Browser
CDN, Web Accelerator, Proxies
and Web Servers will not cache.
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Ask These Questions
1.How often does the data change?
2.Can you tolerate stale data? For
how long?
3.How critical is the data? Can you
lose some of it?
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Caching Strategy : Split Objects
Split objects based on
frequency of change.
Freshers create their profile once,
but apply to jobs very often.
Fresher
Personal Details
Education & Work Ex
Job Application Status
Fresher Profile
Personal Details
Education & Work Ex
Job Applications
Job Application Status
Create Two Objects With Different TTLs
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Cache In-Memory
Put them in
settings file
➔Frequently Accessed Data
➔Infrequently Changing Data
➔Configuration & Settings
Make It Easy To Deploy Just The Settings
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Manually Clear Cache
Cache Forever
Delete as Needed
➔Dynamic Settings
➔Throttles & Blacklists
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Delete on Modification, Rebuild on Read
When data changes, delete it from the cache.
Next read will automatically fill up the cache.
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
DB Design For Scalability
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
First, Know your Data
1. Sizing
How many records in 6 months / 1 year?
2. Query Volumes
How many reads / writes?
3. Hot Tables
Most frequently accessed tables?
4. Criticality of Data
How important is it to not lose data?
5. Availability v/s Consistency
How important is it to not lose data?
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
What is Availability?
Ensuring your system can be
used anytime
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
What is Consistency?
Data is in same state
across all the copies
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
You can’t get both...
You can choose only one
Consistency or Availability
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Two Salesmen Selling Apartments
➔ Each has a diary of sold flats
➔ Call and confirm before selling
What happens when
one salesman is offline,
and a customer calls?
1. He takes the order. But there is
a chance the other salesman
also sold the same flat…
Not Consistent
1. He does not take the order…
Not Available.
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Different Data, Different Guarantees
Sales Transactions must be Consistent
Product Catalog must be Available
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Start with a Normalized Schema...
…which essentially means no
redundant data.
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Optimize Heavy Read Operations
Selectively de-
normalize to
eliminate joins.
1. Counts of objects
2. Summary Statistics
3. Events / Activities
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Denormalize - Number of people watching this Issue
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Not everything needs to be Accurate
Choose
wisely
between
Accuracy
and
Performance
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Create a Separate Reporting Schema
1. Use a Star Schema
2. Aggregate Data
a. by time
hour, day, week, month, quarter, year
b. by region
north, south, east, west, central
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Use a Search Engine
1. Relational DB as Source of Truth
2. SOLR or ElasticSearch as Index
3. Cron Job to update Search Engine
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Things to Avoid in a RDBMS
1. Don’t store files in DB
2. Don’t create task queues
3. Don’t maintain counters
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Use Read Replicas
Use Master-Slave Replication,
and use Slaves for Reads.
Only use for non-transactional reads.
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Shard your Data
1. Choose shard key wisely
Location is usually a poor choice
2. Sharding later is painful
If you think you may need it, shard
upfront.
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Async & Availability - Best Friends
Pre-computation
Slow Jobs
Offload Work to
a Job Queue
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Database Optimization
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Quick Recap
For New Systems - See
Database Design
For Existing Systems - See
Database Optimization
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Asking Deepak for a Notepad
How does he get
you a notepad?
The stationery shop is the
database
1. Waits for the elevator
2. Walks down the street
3. Waits for the pedestrian traffic light
4. Reaches Store
5. Waits for the previous customer
6. Requests for a Notepad
7. Waits for the attendant to search
8. Bonus : Attendant misplaces
notepads
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Three General Techniques
1. Minimize Queries
2. Do More Work in One Trip
3. Make the Query Efficient
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
The Fastest Query...
is Never Executed
Cache Aggressively to Minimize Queries
Don’t use ORM for Reports
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
DB Optimization : More in One Query
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
N + 1 Problem
doc_ids = db.query(“select id from documents where user = ?“, user)
docs = []
for docid in doc_ids:
doc = db.query(“select … from documents where id = ?”, docid)
docs.append(doc)
Query in a Loop = Disaster
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Homogeneous Queries - Union All
Tables
monthly_income
monthly_expenditure
Select ‘income’ as heading, month, income from monthly_income
UNION ALL
Select ‘expenditure’ as heading, month, expenses from monthly_expenditure
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Anti-Pattern : Fetch and Update
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Bulk Operations & Batch Inserts
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
DB Optimization : Efficient Queries
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Find matching lines from a book
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Finding a word in a novel
Full Table Scan
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Finding a Topic in a Tech Book
Index Seek
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Lookup Meaning of a Word
Find by Primary Key
Clustered Index
Data is Sorted
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Find Words like ab* and ac*
Clustered Indexes are
Great for
Range Queries
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Query Planner Algorithm
For each table in a query :
Find constraining columns (where, join)
For each Index on the table :
Find if the index can be used
If multiple indexes :
Find Best Index
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Find if Index can be used
1. Index column must be in where clause
2. For multi-column indexes, the starting columns must
be in where clause
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Best Index?
Index Cardinality
Table Statistics
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
When is an Index NOT Used?
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Slow Queries / Profiler
MySQL Slow Queries Log
MS SQL Profiler
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Anti Pattern : in clause with subquery
Select …. from table1 where id in
(select id from table2 where…)
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
Database Locks & Isolation Levels
Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL
What is a Lock?
Mechanism to prevent data corruption
when multiple people access the
database concurrently.

More Related Content

What's hot (20)

Kettle – Etl Tool
Kettle – Etl ToolKettle – Etl Tool
Kettle – Etl Tool
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
What is ETL?
What is ETL?What is ETL?
What is ETL?
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
Nested queries in database
Nested queries in databaseNested queries in database
Nested queries in database
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
 
Ai platform at scale
Ai platform at scaleAi platform at scale
Ai platform at scale
 
Data mart
Data martData mart
Data mart
 
Data dictionary
Data dictionaryData dictionary
Data dictionary
 
Big Data and Hadoop
Big Data and HadoopBig Data and Hadoop
Big Data and Hadoop
 
Bi 4
Bi 4Bi 4
Bi 4
 
Rehashing
RehashingRehashing
Rehashing
 
Introduction to Data Warehousing
Introduction to Data WarehousingIntroduction to Data Warehousing
Introduction to Data Warehousing
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
pl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledgepl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledge
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
ETL
ETLETL
ETL
 
What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?
 
Isam
IsamIsam
Isam
 
Why shift from ETL to ELT?
Why shift from ETL to ELT?Why shift from ETL to ELT?
Why shift from ETL to ELT?
 

Viewers also liked

The Art of Scalability - Managing growth
The Art of Scalability - Managing growthThe Art of Scalability - Managing growth
The Art of Scalability - Managing growthLorenzo Alberton
 
JShelton Portfolio Preview
JShelton Portfolio PreviewJShelton Portfolio Preview
JShelton Portfolio PreviewJordan Shelton
 
michael-steven-kempenich-resume
michael-steven-kempenich-resumemichael-steven-kempenich-resume
michael-steven-kempenich-resumeMike Kempenich
 
How to Use rebrandly to create, track, and share branded short links
How to Use rebrandly to create, track, and share branded short linksHow to Use rebrandly to create, track, and share branded short links
How to Use rebrandly to create, track, and share branded short linksJaymar Villamor
 
Tien redenen om optimistisch te zijn (Lezing PT Jones, VMx, Gent, 9 juni 2016)
Tien redenen om optimistisch te zijn (Lezing PT Jones, VMx, Gent, 9 juni 2016) Tien redenen om optimistisch te zijn (Lezing PT Jones, VMx, Gent, 9 juni 2016)
Tien redenen om optimistisch te zijn (Lezing PT Jones, VMx, Gent, 9 juni 2016) Peter Tom Jones
 
IntroJones_Terra_Reversa_DE_ZONDVLOED_Mechelen_23-11-2016
IntroJones_Terra_Reversa_DE_ZONDVLOED_Mechelen_23-11-2016IntroJones_Terra_Reversa_DE_ZONDVLOED_Mechelen_23-11-2016
IntroJones_Terra_Reversa_DE_ZONDVLOED_Mechelen_23-11-2016Peter Tom Jones
 
Turning the climate problem into an opportunity (P.T. Jones, Oosterzele, 25-2...
Turning the climate problem into an opportunity (P.T. Jones, Oosterzele, 25-2...Turning the climate problem into an opportunity (P.T. Jones, Oosterzele, 25-2...
Turning the climate problem into an opportunity (P.T. Jones, Oosterzele, 25-2...Peter Tom Jones
 
Active Transport Notes
Active Transport NotesActive Transport Notes
Active Transport Notesericchapman81
 
Aquatic mammals & their adaptation.fully aquatic mammal and amphibian aquatic...
Aquatic mammals & their adaptation.fully aquatic mammal and amphibian aquatic...Aquatic mammals & their adaptation.fully aquatic mammal and amphibian aquatic...
Aquatic mammals & their adaptation.fully aquatic mammal and amphibian aquatic...Anand P P
 
Successful Investing Strategy
Successful Investing StrategySuccessful Investing Strategy
Successful Investing StrategyYodhia Antariksa
 
Botswana Competition Bulletin Issue 4 Volume 4
Botswana Competition Bulletin  Issue 4 Volume 4Botswana Competition Bulletin  Issue 4 Volume 4
Botswana Competition Bulletin Issue 4 Volume 4Gorata Bessie Selelo
 
Placenta & Fetal membrane.Prof.Salah Roshdy
Placenta & Fetal membrane.Prof.Salah RoshdyPlacenta & Fetal membrane.Prof.Salah Roshdy
Placenta & Fetal membrane.Prof.Salah RoshdySalah Roshdy AHMED
 

Viewers also liked (14)

The Art of Scalability - Managing growth
The Art of Scalability - Managing growthThe Art of Scalability - Managing growth
The Art of Scalability - Managing growth
 
JShelton Portfolio Preview
JShelton Portfolio PreviewJShelton Portfolio Preview
JShelton Portfolio Preview
 
Resume - Mohammed Owais Manorwala
Resume - Mohammed Owais ManorwalaResume - Mohammed Owais Manorwala
Resume - Mohammed Owais Manorwala
 
michael-steven-kempenich-resume
michael-steven-kempenich-resumemichael-steven-kempenich-resume
michael-steven-kempenich-resume
 
How to Use rebrandly to create, track, and share branded short links
How to Use rebrandly to create, track, and share branded short linksHow to Use rebrandly to create, track, and share branded short links
How to Use rebrandly to create, track, and share branded short links
 
Tien redenen om optimistisch te zijn (Lezing PT Jones, VMx, Gent, 9 juni 2016)
Tien redenen om optimistisch te zijn (Lezing PT Jones, VMx, Gent, 9 juni 2016) Tien redenen om optimistisch te zijn (Lezing PT Jones, VMx, Gent, 9 juni 2016)
Tien redenen om optimistisch te zijn (Lezing PT Jones, VMx, Gent, 9 juni 2016)
 
IntroJones_Terra_Reversa_DE_ZONDVLOED_Mechelen_23-11-2016
IntroJones_Terra_Reversa_DE_ZONDVLOED_Mechelen_23-11-2016IntroJones_Terra_Reversa_DE_ZONDVLOED_Mechelen_23-11-2016
IntroJones_Terra_Reversa_DE_ZONDVLOED_Mechelen_23-11-2016
 
Turning the climate problem into an opportunity (P.T. Jones, Oosterzele, 25-2...
Turning the climate problem into an opportunity (P.T. Jones, Oosterzele, 25-2...Turning the climate problem into an opportunity (P.T. Jones, Oosterzele, 25-2...
Turning the climate problem into an opportunity (P.T. Jones, Oosterzele, 25-2...
 
Active Transport Notes
Active Transport NotesActive Transport Notes
Active Transport Notes
 
Aquatic mammals & their adaptation.fully aquatic mammal and amphibian aquatic...
Aquatic mammals & their adaptation.fully aquatic mammal and amphibian aquatic...Aquatic mammals & their adaptation.fully aquatic mammal and amphibian aquatic...
Aquatic mammals & their adaptation.fully aquatic mammal and amphibian aquatic...
 
Successful Investing Strategy
Successful Investing StrategySuccessful Investing Strategy
Successful Investing Strategy
 
Botswana Competition Bulletin Issue 4 Volume 4
Botswana Competition Bulletin  Issue 4 Volume 4Botswana Competition Bulletin  Issue 4 Volume 4
Botswana Competition Bulletin Issue 4 Volume 4
 
Priti_Pauniya_2017
Priti_Pauniya_2017Priti_Pauniya_2017
Priti_Pauniya_2017
 
Placenta & Fetal membrane.Prof.Salah Roshdy
Placenta & Fetal membrane.Prof.Salah RoshdyPlacenta & Fetal membrane.Prof.Salah Roshdy
Placenta & Fetal membrane.Prof.Salah Roshdy
 

Similar to Scalability and Performance

Double Your Hadoop Hardware Performance with SmartSense
Double Your Hadoop Hardware Performance with SmartSenseDouble Your Hadoop Hardware Performance with SmartSense
Double Your Hadoop Hardware Performance with SmartSenseHortonworks
 
Rediscover Software Development Edward Hieatt Web Summit 2014
Rediscover Software Development Edward Hieatt Web Summit 2014Rediscover Software Development Edward Hieatt Web Summit 2014
Rediscover Software Development Edward Hieatt Web Summit 2014VMware Tanzu
 
Confessions of the Tester
Confessions of the TesterConfessions of the Tester
Confessions of the TesterDelphix
 
EMC Big Data | Hadoop Starter Kit | EMC Forum 2014
EMC Big Data | Hadoop Starter Kit | EMC Forum 2014EMC Big Data | Hadoop Starter Kit | EMC Forum 2014
EMC Big Data | Hadoop Starter Kit | EMC Forum 2014EMC
 
PeopleSoft WorkCenters: Meeting User Demands For Simple Intuitive Business Ap...
PeopleSoft WorkCenters: Meeting User Demands For Simple Intuitive Business Ap...PeopleSoft WorkCenters: Meeting User Demands For Simple Intuitive Business Ap...
PeopleSoft WorkCenters: Meeting User Demands For Simple Intuitive Business Ap...Emtec Inc.
 
Making Hadoop based analytics simple for everyone to use
Making Hadoop based analytics simple for everyone to useMaking Hadoop based analytics simple for everyone to use
Making Hadoop based analytics simple for everyone to useSwiss Big Data User Group
 
Top10 list planningpostgresdeployment.2014
Top10 list planningpostgresdeployment.2014Top10 list planningpostgresdeployment.2014
Top10 list planningpostgresdeployment.2014EDB
 
Accelerating breakthrough business technologies in atlanta, tag featured spea...
Accelerating breakthrough business technologies in atlanta, tag featured spea...Accelerating breakthrough business technologies in atlanta, tag featured spea...
Accelerating breakthrough business technologies in atlanta, tag featured spea...Melanie Brandt
 
Pivotal CenturyLink Cloud Platform Seminar Presentations: Software Kept Eatin...
Pivotal CenturyLink Cloud Platform Seminar Presentations: Software Kept Eatin...Pivotal CenturyLink Cloud Platform Seminar Presentations: Software Kept Eatin...
Pivotal CenturyLink Cloud Platform Seminar Presentations: Software Kept Eatin...VMware Tanzu
 
Dissecting and Attacking RMI Frameworks
Dissecting and Attacking RMI FrameworksDissecting and Attacking RMI Frameworks
Dissecting and Attacking RMI FrameworksOnapsis Inc.
 
InfluxDB Enterprise Architectural Patterns | Craig Hobbs | InfluxData
InfluxDB Enterprise Architectural Patterns | Craig Hobbs | InfluxDataInfluxDB Enterprise Architectural Patterns | Craig Hobbs | InfluxData
InfluxDB Enterprise Architectural Patterns | Craig Hobbs | InfluxDataInfluxData
 
5 must haves for MSPs webinar
5 must haves for MSPs webinar5 must haves for MSPs webinar
5 must haves for MSPs webinarAccelOps, Inc.
 
NVMe and Flash – Make Your Storage Great Again!
NVMe and Flash – Make Your Storage Great Again!NVMe and Flash – Make Your Storage Great Again!
NVMe and Flash – Make Your Storage Great Again!DataCore Software
 
Apachecon 2014 Keynote: The Apache Way in the Cloud with Cloud Foundry
Apachecon 2014 Keynote: The Apache Way in the Cloud with Cloud Foundry Apachecon 2014 Keynote: The Apache Way in the Cloud with Cloud Foundry
Apachecon 2014 Keynote: The Apache Way in the Cloud with Cloud Foundry James Watters
 
Strategies for on premise to Google Cloud migration - Mateusz Pytel, GetInData
Strategies for on premise to Google Cloud migration - Mateusz Pytel, GetInDataStrategies for on premise to Google Cloud migration - Mateusz Pytel, GetInData
Strategies for on premise to Google Cloud migration - Mateusz Pytel, GetInDataGetInData
 
Agile Embedded Software Development, what's wrong with it?
Agile Embedded Software Development, what's wrong with it?Agile Embedded Software Development, what's wrong with it?
Agile Embedded Software Development, what's wrong with it?Andrea Tomasini
 
Rescue your Big Data from Downtime with HP Operations Bridge and Apache Hadoop
Rescue your Big Data from Downtime with HP Operations Bridge and Apache HadoopRescue your Big Data from Downtime with HP Operations Bridge and Apache Hadoop
Rescue your Big Data from Downtime with HP Operations Bridge and Apache HadoopHortonworks
 
ICIC 2014 High volume, High Quality Patent Translation across Multiple Domain...
ICIC 2014 High volume, High Quality Patent Translation across Multiple Domain...ICIC 2014 High volume, High Quality Patent Translation across Multiple Domain...
ICIC 2014 High volume, High Quality Patent Translation across Multiple Domain...Dr. Haxel Consult
 
Omaha rug customer 2 cloud customer facing hcm ppt aug 2014
Omaha rug customer 2 cloud customer facing hcm ppt aug 2014Omaha rug customer 2 cloud customer facing hcm ppt aug 2014
Omaha rug customer 2 cloud customer facing hcm ppt aug 2014tecrecruiter
 
Enterprise Data Science at Scale
Enterprise Data Science at ScaleEnterprise Data Science at Scale
Enterprise Data Science at ScaleArtem Ervits
 

Similar to Scalability and Performance (20)

Double Your Hadoop Hardware Performance with SmartSense
Double Your Hadoop Hardware Performance with SmartSenseDouble Your Hadoop Hardware Performance with SmartSense
Double Your Hadoop Hardware Performance with SmartSense
 
Rediscover Software Development Edward Hieatt Web Summit 2014
Rediscover Software Development Edward Hieatt Web Summit 2014Rediscover Software Development Edward Hieatt Web Summit 2014
Rediscover Software Development Edward Hieatt Web Summit 2014
 
Confessions of the Tester
Confessions of the TesterConfessions of the Tester
Confessions of the Tester
 
EMC Big Data | Hadoop Starter Kit | EMC Forum 2014
EMC Big Data | Hadoop Starter Kit | EMC Forum 2014EMC Big Data | Hadoop Starter Kit | EMC Forum 2014
EMC Big Data | Hadoop Starter Kit | EMC Forum 2014
 
PeopleSoft WorkCenters: Meeting User Demands For Simple Intuitive Business Ap...
PeopleSoft WorkCenters: Meeting User Demands For Simple Intuitive Business Ap...PeopleSoft WorkCenters: Meeting User Demands For Simple Intuitive Business Ap...
PeopleSoft WorkCenters: Meeting User Demands For Simple Intuitive Business Ap...
 
Making Hadoop based analytics simple for everyone to use
Making Hadoop based analytics simple for everyone to useMaking Hadoop based analytics simple for everyone to use
Making Hadoop based analytics simple for everyone to use
 
Top10 list planningpostgresdeployment.2014
Top10 list planningpostgresdeployment.2014Top10 list planningpostgresdeployment.2014
Top10 list planningpostgresdeployment.2014
 
Accelerating breakthrough business technologies in atlanta, tag featured spea...
Accelerating breakthrough business technologies in atlanta, tag featured spea...Accelerating breakthrough business technologies in atlanta, tag featured spea...
Accelerating breakthrough business technologies in atlanta, tag featured spea...
 
Pivotal CenturyLink Cloud Platform Seminar Presentations: Software Kept Eatin...
Pivotal CenturyLink Cloud Platform Seminar Presentations: Software Kept Eatin...Pivotal CenturyLink Cloud Platform Seminar Presentations: Software Kept Eatin...
Pivotal CenturyLink Cloud Platform Seminar Presentations: Software Kept Eatin...
 
Dissecting and Attacking RMI Frameworks
Dissecting and Attacking RMI FrameworksDissecting and Attacking RMI Frameworks
Dissecting and Attacking RMI Frameworks
 
InfluxDB Enterprise Architectural Patterns | Craig Hobbs | InfluxData
InfluxDB Enterprise Architectural Patterns | Craig Hobbs | InfluxDataInfluxDB Enterprise Architectural Patterns | Craig Hobbs | InfluxData
InfluxDB Enterprise Architectural Patterns | Craig Hobbs | InfluxData
 
5 must haves for MSPs webinar
5 must haves for MSPs webinar5 must haves for MSPs webinar
5 must haves for MSPs webinar
 
NVMe and Flash – Make Your Storage Great Again!
NVMe and Flash – Make Your Storage Great Again!NVMe and Flash – Make Your Storage Great Again!
NVMe and Flash – Make Your Storage Great Again!
 
Apachecon 2014 Keynote: The Apache Way in the Cloud with Cloud Foundry
Apachecon 2014 Keynote: The Apache Way in the Cloud with Cloud Foundry Apachecon 2014 Keynote: The Apache Way in the Cloud with Cloud Foundry
Apachecon 2014 Keynote: The Apache Way in the Cloud with Cloud Foundry
 
Strategies for on premise to Google Cloud migration - Mateusz Pytel, GetInData
Strategies for on premise to Google Cloud migration - Mateusz Pytel, GetInDataStrategies for on premise to Google Cloud migration - Mateusz Pytel, GetInData
Strategies for on premise to Google Cloud migration - Mateusz Pytel, GetInData
 
Agile Embedded Software Development, what's wrong with it?
Agile Embedded Software Development, what's wrong with it?Agile Embedded Software Development, what's wrong with it?
Agile Embedded Software Development, what's wrong with it?
 
Rescue your Big Data from Downtime with HP Operations Bridge and Apache Hadoop
Rescue your Big Data from Downtime with HP Operations Bridge and Apache HadoopRescue your Big Data from Downtime with HP Operations Bridge and Apache Hadoop
Rescue your Big Data from Downtime with HP Operations Bridge and Apache Hadoop
 
ICIC 2014 High volume, High Quality Patent Translation across Multiple Domain...
ICIC 2014 High volume, High Quality Patent Translation across Multiple Domain...ICIC 2014 High volume, High Quality Patent Translation across Multiple Domain...
ICIC 2014 High volume, High Quality Patent Translation across Multiple Domain...
 
Omaha rug customer 2 cloud customer facing hcm ppt aug 2014
Omaha rug customer 2 cloud customer facing hcm ppt aug 2014Omaha rug customer 2 cloud customer facing hcm ppt aug 2014
Omaha rug customer 2 cloud customer facing hcm ppt aug 2014
 
Enterprise Data Science at Scale
Enterprise Data Science at ScaleEnterprise Data Science at Scale
Enterprise Data Science at Scale
 

Recently uploaded

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Recently uploaded (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

Scalability and Performance

  • 1. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Scalability & Performance Principles & Techniques
  • 2. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL What is a Performance Problem? System is Slow for a Single User
  • 3. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL What is a Scalability Problem? Fast for Single User but Slow under Heavy Load
  • 4. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL How do you measure Performance? Response Time for 1 User i.e. how long the user waits
  • 5. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Number of Users that can work simultaneously with acceptable performance How do you measure Scalability?
  • 6. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL 95% of time is spent in fronten
  • 7. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL But, we won’t talk about frontend performance improvements today.
  • 8. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Let’s talk about backend
  • 9. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Relationship between Performance & Scalability
  • 10. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Performance & Scalability Mantra Strive for maximum throughput with acceptable response times
  • 11. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL To Improve Scalability... Improve Performance Add Capacity OR
  • 12. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Response Time : 1s Workers : 4 Machines : 1 Poor Performance & Scalability 4 requests/second Slowest response : 1s
  • 13. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Better Performance & Scalability Response Time : 500ms Workers : 4 Machines : 1 8 requests/second Slowest response : 1s
  • 14. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Even Better Performance ... Response Time : 100ms Workers : 4 Machines : 1 40 requests/second Slowest response : 1s
  • 15. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Great Performance & Scalability Response Time : 10ms Workers : 4 Machines : 1 400 requests/second Slowest response : 1s
  • 16. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL You cannot make response time 0ms To support more than 400 requests…. Increase Number of Workers
  • 17. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL With double the workers... Response Time : 10ms Workers : 8 Machines : 2 800 requests/second Slowest response : 1s
  • 18. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL and with even more workers... Response Time : 10ms Workers : 16 Machines : 4 1600 requests/second Slowest response : 1s
  • 19. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Coming Back To Reality Increasing Capacity Should Increase Throughput It Does Not. Not Until You Design Your Application Correctly.
  • 20. Copyright © 2014-2017 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL You have to increase capacity at each layer. Web & App Server Cache Server, Database CPU, Network, Disk Why? And there are locks. Database Locks Synchronized Code Blocks. Mutexes File System Locks
  • 21. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL What should our goal be? 1. Reduce Response Times 2. Make it possible to add more Capacity
  • 22. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Scaling Data Storage
  • 23. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Browser Edge Server Load Balancer Web Server App Server REST API DatabaseUser Browser Edge Server Load Balancer Web Server App Server REST API DatabaseUser Browser Cache CDN Web Accelerator Nginx / Apache Object Cache Akamai AWS Cloudfront VarnishAll Browsers All Mobiles mod_proxy Static Variables Redis, Memcached EHCache Less Granularity, More Effective More Granularity, Less Effective
  • 24. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL HTTP Caching Strategy Cache Forever Cache-Control : maxage Expires : Do Not Cache Cache-Control : maxage=-1 Expires : 1970-01-01 Cache Temporarily Cache-Control : maxage=3600 Expires : <now plus 1 hour> ➔ Use for HTML pages with dynamic content ➔ Avoid for static resources ➔ Use for high traffic public html pages - i.e. homepage ➔ Specify etag or expires header to use conditional GET ➔ Use javascript to load user specific data ➔ Avoid for static resources ➔ Use for static resources - css, images, js ➔ Change URL in HTML when resource is modified ➔ Use a pre-processor to simplify management
  • 25. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Cache Temporarily Render this using JS after page load Cache for 2h. Don’t overdo. You cannot change the URL of your homepage if the content has to change.
  • 26. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Cache Static Files Permanently Static files are loaded from browser cache Cache Forever If base.css changes, serve it from base.css?v=2 New URL. Fresh Download.
  • 27. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Cache-Control: private Logged in user- specific pages or APIs. Only Cached By Browser CDN, Web Accelerator, Proxies and Web Servers will not cache.
  • 28. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Ask These Questions 1.How often does the data change? 2.Can you tolerate stale data? For how long? 3.How critical is the data? Can you lose some of it?
  • 29. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Caching Strategy : Split Objects Split objects based on frequency of change. Freshers create their profile once, but apply to jobs very often. Fresher Personal Details Education & Work Ex Job Application Status Fresher Profile Personal Details Education & Work Ex Job Applications Job Application Status Create Two Objects With Different TTLs
  • 30. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Cache In-Memory Put them in settings file ➔Frequently Accessed Data ➔Infrequently Changing Data ➔Configuration & Settings Make It Easy To Deploy Just The Settings
  • 31. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Manually Clear Cache Cache Forever Delete as Needed ➔Dynamic Settings ➔Throttles & Blacklists
  • 32. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Delete on Modification, Rebuild on Read When data changes, delete it from the cache. Next read will automatically fill up the cache.
  • 33. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL DB Design For Scalability
  • 34. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL First, Know your Data 1. Sizing How many records in 6 months / 1 year? 2. Query Volumes How many reads / writes? 3. Hot Tables Most frequently accessed tables? 4. Criticality of Data How important is it to not lose data? 5. Availability v/s Consistency How important is it to not lose data?
  • 35. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL What is Availability? Ensuring your system can be used anytime
  • 36. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL What is Consistency? Data is in same state across all the copies
  • 37. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL You can’t get both... You can choose only one Consistency or Availability
  • 38. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Two Salesmen Selling Apartments ➔ Each has a diary of sold flats ➔ Call and confirm before selling What happens when one salesman is offline, and a customer calls? 1. He takes the order. But there is a chance the other salesman also sold the same flat… Not Consistent 1. He does not take the order… Not Available.
  • 39. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Different Data, Different Guarantees Sales Transactions must be Consistent Product Catalog must be Available
  • 40. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Start with a Normalized Schema... …which essentially means no redundant data.
  • 41. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Optimize Heavy Read Operations Selectively de- normalize to eliminate joins. 1. Counts of objects 2. Summary Statistics 3. Events / Activities
  • 42. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Denormalize - Number of people watching this Issue
  • 43. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Not everything needs to be Accurate Choose wisely between Accuracy and Performance
  • 44. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Create a Separate Reporting Schema 1. Use a Star Schema 2. Aggregate Data a. by time hour, day, week, month, quarter, year b. by region north, south, east, west, central
  • 45. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Use a Search Engine 1. Relational DB as Source of Truth 2. SOLR or ElasticSearch as Index 3. Cron Job to update Search Engine
  • 46. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Things to Avoid in a RDBMS 1. Don’t store files in DB 2. Don’t create task queues 3. Don’t maintain counters
  • 47. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Use Read Replicas Use Master-Slave Replication, and use Slaves for Reads. Only use for non-transactional reads.
  • 48. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Shard your Data 1. Choose shard key wisely Location is usually a poor choice 2. Sharding later is painful If you think you may need it, shard upfront.
  • 49. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Async & Availability - Best Friends Pre-computation Slow Jobs Offload Work to a Job Queue
  • 50. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Database Optimization
  • 51. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Quick Recap For New Systems - See Database Design For Existing Systems - See Database Optimization
  • 52. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Asking Deepak for a Notepad How does he get you a notepad? The stationery shop is the database 1. Waits for the elevator 2. Walks down the street 3. Waits for the pedestrian traffic light 4. Reaches Store 5. Waits for the previous customer 6. Requests for a Notepad 7. Waits for the attendant to search 8. Bonus : Attendant misplaces notepads
  • 53. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Three General Techniques 1. Minimize Queries 2. Do More Work in One Trip 3. Make the Query Efficient
  • 54. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL The Fastest Query... is Never Executed Cache Aggressively to Minimize Queries Don’t use ORM for Reports
  • 55. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL DB Optimization : More in One Query
  • 56. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL N + 1 Problem doc_ids = db.query(“select id from documents where user = ?“, user) docs = [] for docid in doc_ids: doc = db.query(“select … from documents where id = ?”, docid) docs.append(doc) Query in a Loop = Disaster
  • 57. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Homogeneous Queries - Union All Tables monthly_income monthly_expenditure Select ‘income’ as heading, month, income from monthly_income UNION ALL Select ‘expenditure’ as heading, month, expenses from monthly_expenditure
  • 58. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Anti-Pattern : Fetch and Update
  • 59. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Bulk Operations & Batch Inserts
  • 60. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL DB Optimization : Efficient Queries
  • 61. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Find matching lines from a book
  • 62. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Finding a word in a novel Full Table Scan
  • 63. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Finding a Topic in a Tech Book Index Seek
  • 64. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Lookup Meaning of a Word Find by Primary Key Clustered Index Data is Sorted
  • 65. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Find Words like ab* and ac* Clustered Indexes are Great for Range Queries
  • 66. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Query Planner Algorithm For each table in a query : Find constraining columns (where, join) For each Index on the table : Find if the index can be used If multiple indexes : Find Best Index
  • 67. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Find if Index can be used 1. Index column must be in where clause 2. For multi-column indexes, the starting columns must be in where clause
  • 68. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Best Index? Index Cardinality Table Statistics
  • 69. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL When is an Index NOT Used?
  • 70. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Slow Queries / Profiler MySQL Slow Queries Log MS SQL Profiler
  • 71. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Anti Pattern : in clause with subquery Select …. from table1 where id in (select id from table2 where…)
  • 72. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL Database Locks & Isolation Levels
  • 73. Copyright © 2014 HashedIn Technologies Pvt Ltd. All rights reserved. – CONFIDENTIAL What is a Lock? Mechanism to prevent data corruption when multiple people access the database concurrently.