SlideShare une entreprise Scribd logo
1  sur  19
Caching Up is Hard To
Do
Chad McCallum
ASP.NET MVP
iQmetrix Software
www.rtigger.com - @ChadEmm
Improving the performance of your web
services
Here’s your API
Client makes a request Bounces around the
internet to web server
Web server runs
application, queries DB
Database returns data
from query
Application serializes
response and writes to
client
Bounces back through
internet to client
Client receives data
Client The Internet Web Server Database
An example request
Client The Internet Web Server Database
Client makes a request Bounces around the
internet to web server
Web server runs
application, queries DB
Database returns data
from query
Application serializes
response and writes to
client
Bounces back through
internet to client
Client receives data
270ms
598ms3474ms
4342ms
528kb
Start at the data
• Optimize the database server
• Logical Design – efficient queries, application-specific schema, constraints,
normalization
• Physical Design – indexes, table & system settings, partitions, denormalization
• Hardware – SSDs, RAM, CPU, Network
Between your App and the Data
• Reduce the complexity of your calls – get only the data you need
• Reduce the number of calls – return all the required data in one query
• Make calls async – perform multiple queries at the same time*
• The fastest query is the one you never make
• Cache the result of common queries in an application-level or shared cache
598ms 315ms
47%
Application Time
Caching Data
• Great for static or relatively unchanged data
• Product Catalogs
• Order History
• Not so great for volatile data
• Store Quantity
• Messages
• Comes with a memory price
• Shared Cache when working with a web farm
Inside your App
• Standard “MVC” Flow
• Request comes into Web Server over network connection
• Framework parses request URL and other variables to determine which
controller and method to execute, checking against routes
• Framework creates instance of controller class and passes copy of request
object to appropriate method
• Method executes, returning an object to be sent in response
• Framework serializes response object into preferred type as requested by
client
• Web server writes response back to client over network connection
Inside your App
• The most we can reasonably do is optimize our controller’s method
• “Reasonably” meaning not doing crazy things to the underlying framework
code / dependencies
• The fastest method is one you don’t execute
• Cache the serialized result of common API calls
598ms 296ms
51%
Application Time
Caching Responses
• Great for endpoints that don’t take parameters
• Get
• Not so great for endpoints that do take parameters
• Get By ID
• reports with date ranges
• Get with filters
• Cache all supported serialization formats
• Same cache concerns – memory usage, shared cache in farm setup
From Server to Client
• We can’t really change the topology of a client’s network connection
• We can send less data
• HTTP Compression
3474ms 1083ms
69%
528kb 129kb
76%
Response Size Response Time
HTTP Compression
• Trading response size for server CPU cycles
• Output can be cached (and often is) by web server to avoid re-
compressing the same thing
• Client requests compression using Accept-Encoding header
598ms 624ms
4%
Application Time
Paging
• Don’t send everything!
• Only returning 20 items
• Page objects using OData Queries in WebAPI
• Returning IEnumerable<T> will page in-memory
• Returning IQueryable<T> will (attempt to) page at the database layer
3474ms 7ms
99.8%
528kb 10kb
98.1%
Response Size Response Time
Conditional Headers
• Server can send either an ETag and/or Last-Modified header with
response
• ETag = identifier for a specific version of a resource
• Last-Modified = the last time this resource was modified
• Clients can include that data in subsequent requests
• If-None-Match: “etag value”
• If-Modified-Since: (http date)
• Server can respond with a simple “304 Not Modified” response
Conditional Headers
3474ms <1 ms
99.9%
528kb 0.3kb
99.9%
• Avoid database calls to validate requests
• Cache last modified times & etag values
• May have to modify client code to retain and send Last-Modified and
ETag values
• Most browsers will automatically include If-Modified-Since, but some do
not include If-None-Match
• Non-browser code (SDKs, WebClient, HttpClient)
Response Size Response Time
598ms 323ms
54%
Application Time
Client-Side Caching
• Most browsers have a local cache – tell your clients to use it!
• Expires header tells client how long it can reuse a response
• Expires: Thu, 03 Apr 2014 03:19:37 GMT
• Cache-Control: max-age=## (where ## is seconds) header does the
same, but applies to more than just the client cache…
• In either case it’s up to the client whether it uses the cache or not
• Most browsers cache aggressively
Intermediate Caching
• Cache-Control header specifies who can cache, what they can
cache, and how things can be cached
• Public / Private – whether a response can be reused for all requests, or is
specific to a certain user
• max-age – the longest a response can be cached in seconds (overrides Expires
header)
• must-revalidate – if the response expires, must revalidate it with the server
before using it again
• no-cache – must check with the server first before returning a cached
response
Client-Side Caching
• Great for static or relatively static data
• Static HTML, JS, CSS files, or read-only lists of data that rarely change
• Not so great for dynamic or mission-critical data
• Hard to force clients to get latest version of data when they don’t even talk to
the server
• If you have to update before Expires or Max-Age runs out, you’ve got a
problem
4342ms 100ms
97.7%
Response Time
Review
• Optimize your database for your application
• Cache on the server
• Common database calls
• Serialized results
• Send less data
• HTTP Compression
• Paging
• Conditional Headers / 304 Not Modified
• Cache on the client
• Expires and Cache-Control headers
Abracadabra!
4342
100
0
500
1000
1500
2000
2500
3000
3500
4000
4500
5000
Milliseconds
Before After
Chad McCallum
www.rtigger.com
@ChadEmm

Contenu connexe

Tendances

How to boost performance of your rails app using dynamo db and memcached
How to boost performance of your rails app using dynamo db and memcachedHow to boost performance of your rails app using dynamo db and memcached
How to boost performance of your rails app using dynamo db and memcachedAndolasoft Inc
 
Azure database services for PostgreSQL and MySQL
Azure database services for PostgreSQL and MySQLAzure database services for PostgreSQL and MySQL
Azure database services for PostgreSQL and MySQLAmit Banerjee
 
Azure API Manegement Introduction and Integeration with BizTalk
Azure API Manegement Introduction and Integeration with BizTalkAzure API Manegement Introduction and Integeration with BizTalk
Azure API Manegement Introduction and Integeration with BizTalkShailesh Dwivedi
 
Tips for Optimizing Web Performance
Tips for Optimizing Web PerformanceTips for Optimizing Web Performance
Tips for Optimizing Web PerformanceThousandEyes
 
Leveraging ApsaraDB to Deploy Business Data on the Cloud
Leveraging ApsaraDB to Deploy Business Data on the CloudLeveraging ApsaraDB to Deploy Business Data on the Cloud
Leveraging ApsaraDB to Deploy Business Data on the CloudOliver Theobald
 
Cloud Design Pattern part2
Cloud Design Pattern part2Cloud Design Pattern part2
Cloud Design Pattern part2Masashi Narumoto
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websitesoazabir
 
How to improve your apache web server’s performance
How to improve your apache web server’s performanceHow to improve your apache web server’s performance
How to improve your apache web server’s performanceAndolasoft Inc
 
What SQL DBAs need to know about SharePoint
What SQL DBAs need to know about SharePointWhat SQL DBAs need to know about SharePoint
What SQL DBAs need to know about SharePointJ.D. Wade
 
Arquitectura para Windows Azure: Pienso, luego existo by Fernando Machado
Arquitectura para Windows Azure: Pienso, luego existo by Fernando MachadoArquitectura para Windows Azure: Pienso, luego existo by Fernando Machado
Arquitectura para Windows Azure: Pienso, luego existo by Fernando Machado.NET Conf UY
 
DDD and CQRS for .NET Developers
DDD and CQRS for .NET DevelopersDDD and CQRS for .NET Developers
DDD and CQRS for .NET DevelopersAllan Mangune
 
Modern Cloud Fundamentals: Misconceptions and Industry Trends
Modern Cloud Fundamentals: Misconceptions and Industry TrendsModern Cloud Fundamentals: Misconceptions and Industry Trends
Modern Cloud Fundamentals: Misconceptions and Industry TrendsChristopher Bennage
 
Azure SQL Managed Instance - SqlBits 2019
Azure SQL Managed Instance - SqlBits 2019Azure SQL Managed Instance - SqlBits 2019
Azure SQL Managed Instance - SqlBits 2019Jovan Popovic
 
(ATS6-PLAT09) Deploying Applications on load balanced AEP servers for high av...
(ATS6-PLAT09) Deploying Applications on load balanced AEP servers for high av...(ATS6-PLAT09) Deploying Applications on load balanced AEP servers for high av...
(ATS6-PLAT09) Deploying Applications on load balanced AEP servers for high av...BIOVIA
 
Optimizing Data Management for MongoDB
Optimizing Data Management for MongoDBOptimizing Data Management for MongoDB
Optimizing Data Management for MongoDBImanis Data
 
Monitoring CDN Performance
Monitoring CDN PerformanceMonitoring CDN Performance
Monitoring CDN PerformanceThousandEyes
 

Tendances (20)

How to boost performance of your rails app using dynamo db and memcached
How to boost performance of your rails app using dynamo db and memcachedHow to boost performance of your rails app using dynamo db and memcached
How to boost performance of your rails app using dynamo db and memcached
 
Azure database services for PostgreSQL and MySQL
Azure database services for PostgreSQL and MySQLAzure database services for PostgreSQL and MySQL
Azure database services for PostgreSQL and MySQL
 
Azure API Manegement Introduction and Integeration with BizTalk
Azure API Manegement Introduction and Integeration with BizTalkAzure API Manegement Introduction and Integeration with BizTalk
Azure API Manegement Introduction and Integeration with BizTalk
 
Tips for Optimizing Web Performance
Tips for Optimizing Web PerformanceTips for Optimizing Web Performance
Tips for Optimizing Web Performance
 
Closing the door on application performance problems
Closing the door on application performance problemsClosing the door on application performance problems
Closing the door on application performance problems
 
Leveraging ApsaraDB to Deploy Business Data on the Cloud
Leveraging ApsaraDB to Deploy Business Data on the CloudLeveraging ApsaraDB to Deploy Business Data on the Cloud
Leveraging ApsaraDB to Deploy Business Data on the Cloud
 
Cloud Design Pattern part2
Cloud Design Pattern part2Cloud Design Pattern part2
Cloud Design Pattern part2
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites
 
How to improve your apache web server’s performance
How to improve your apache web server’s performanceHow to improve your apache web server’s performance
How to improve your apache web server’s performance
 
Key to optimal end user experience
Key to optimal end user experienceKey to optimal end user experience
Key to optimal end user experience
 
What SQL DBAs need to know about SharePoint
What SQL DBAs need to know about SharePointWhat SQL DBAs need to know about SharePoint
What SQL DBAs need to know about SharePoint
 
Arquitectura para Windows Azure: Pienso, luego existo by Fernando Machado
Arquitectura para Windows Azure: Pienso, luego existo by Fernando MachadoArquitectura para Windows Azure: Pienso, luego existo by Fernando Machado
Arquitectura para Windows Azure: Pienso, luego existo by Fernando Machado
 
DDD and CQRS for .NET Developers
DDD and CQRS for .NET DevelopersDDD and CQRS for .NET Developers
DDD and CQRS for .NET Developers
 
Modern Cloud Fundamentals: Misconceptions and Industry Trends
Modern Cloud Fundamentals: Misconceptions and Industry TrendsModern Cloud Fundamentals: Misconceptions and Industry Trends
Modern Cloud Fundamentals: Misconceptions and Industry Trends
 
Web Servers (ppt)
Web Servers (ppt)Web Servers (ppt)
Web Servers (ppt)
 
Azure SQL Managed Instance - SqlBits 2019
Azure SQL Managed Instance - SqlBits 2019Azure SQL Managed Instance - SqlBits 2019
Azure SQL Managed Instance - SqlBits 2019
 
(ATS6-PLAT09) Deploying Applications on load balanced AEP servers for high av...
(ATS6-PLAT09) Deploying Applications on load balanced AEP servers for high av...(ATS6-PLAT09) Deploying Applications on load balanced AEP servers for high av...
(ATS6-PLAT09) Deploying Applications on load balanced AEP servers for high av...
 
Optimizing Data Management for MongoDB
Optimizing Data Management for MongoDBOptimizing Data Management for MongoDB
Optimizing Data Management for MongoDB
 
Using Dockers for DB Monitoring
Using Dockers for DB MonitoringUsing Dockers for DB Monitoring
Using Dockers for DB Monitoring
 
Monitoring CDN Performance
Monitoring CDN PerformanceMonitoring CDN Performance
Monitoring CDN Performance
 

En vedette

Ready, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming languageReady, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming languageRTigger
 
Windows 8 programming with html and java script
Windows 8 programming with html and java scriptWindows 8 programming with html and java script
Windows 8 programming with html and java scriptRTigger
 
Open regina
Open reginaOpen regina
Open reginaRTigger
 
Open source web services
Open source web servicesOpen source web services
Open source web servicesRTigger
 
How to hire a hacker
How to hire a hackerHow to hire a hacker
How to hire a hackerRTigger
 
You Can't Buy Agile
You Can't Buy AgileYou Can't Buy Agile
You Can't Buy AgileRTigger
 
Single page apps and the web of tomorrow
Single page apps and the web of tomorrowSingle page apps and the web of tomorrow
Single page apps and the web of tomorrowRTigger
 
Async in .NET
Async in .NETAsync in .NET
Async in .NETRTigger
 
E government solution by cotsys version 1-5
E government solution by cotsys version 1-5E government solution by cotsys version 1-5
E government solution by cotsys version 1-5COTSYS LTD
 
Seamless Integration of Data in E Government
Seamless Integration of Data in E Government Seamless Integration of Data in E Government
Seamless Integration of Data in E Government WSO2
 
Modernization Of State Government Treasury
Modernization Of State Government TreasuryModernization Of State Government Treasury
Modernization Of State Government TreasuryAnirban Mukerji
 
Huawei Solutions for Smart Cities
Huawei Solutions for Smart CitiesHuawei Solutions for Smart Cities
Huawei Solutions for Smart CitiesMuhammad Rauf Akram
 

En vedette (16)

Ready, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming languageReady, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming language
 
Windows 8 programming with html and java script
Windows 8 programming with html and java scriptWindows 8 programming with html and java script
Windows 8 programming with html and java script
 
Aruna Kumar_Resume
Aruna Kumar_ResumeAruna Kumar_Resume
Aruna Kumar_Resume
 
Open regina
Open reginaOpen regina
Open regina
 
Open source web services
Open source web servicesOpen source web services
Open source web services
 
How to hire a hacker
How to hire a hackerHow to hire a hacker
How to hire a hacker
 
You Can't Buy Agile
You Can't Buy AgileYou Can't Buy Agile
You Can't Buy Agile
 
Single page apps and the web of tomorrow
Single page apps and the web of tomorrowSingle page apps and the web of tomorrow
Single page apps and the web of tomorrow
 
Async in .NET
Async in .NETAsync in .NET
Async in .NET
 
E government solution by cotsys version 1-5
E government solution by cotsys version 1-5E government solution by cotsys version 1-5
E government solution by cotsys version 1-5
 
Seamless Integration of Data in E Government
Seamless Integration of Data in E Government Seamless Integration of Data in E Government
Seamless Integration of Data in E Government
 
Modernization Of State Government Treasury
Modernization Of State Government TreasuryModernization Of State Government Treasury
Modernization Of State Government Treasury
 
Biometric identification
Biometric identificationBiometric identification
Biometric identification
 
E-government architecture
E-government architectureE-government architecture
E-government architecture
 
e-governance
e-governancee-governance
e-governance
 
Huawei Solutions for Smart Cities
Huawei Solutions for Smart CitiesHuawei Solutions for Smart Cities
Huawei Solutions for Smart Cities
 

Similaire à Caching up is hard to do: Improving your Web Services' Performance

Performance and Scalability Tuning
Performance and Scalability TuningPerformance and Scalability Tuning
Performance and Scalability TuningAndres March
 
Configuring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceConfiguring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceSpark::red
 
Expect the unexpected: Prepare for failures in microservices
Expect the unexpected: Prepare for failures in microservicesExpect the unexpected: Prepare for failures in microservices
Expect the unexpected: Prepare for failures in microservicesBhakti Mehta
 
Content Devilery Network
Content Devilery NetworkContent Devilery Network
Content Devilery NetworkSanjiv Pradhan
 
Building & Testing Scalable Rails Applications
Building & Testing Scalable Rails ApplicationsBuilding & Testing Scalable Rails Applications
Building & Testing Scalable Rails Applicationsevilmike
 
IBM Maximo Performance Tuning
IBM Maximo Performance TuningIBM Maximo Performance Tuning
IBM Maximo Performance TuningFMMUG
 
SQL Server ASYNC_NETWORK_IO Wait Type Explained
SQL Server ASYNC_NETWORK_IO Wait Type ExplainedSQL Server ASYNC_NETWORK_IO Wait Type Explained
SQL Server ASYNC_NETWORK_IO Wait Type ExplainedConfio Software
 
Resilience planning and how the empire strikes back
Resilience planning and how the empire strikes backResilience planning and how the empire strikes back
Resilience planning and how the empire strikes backBhakti Mehta
 
Boost the Performance of SharePoint Today!
Boost the Performance of SharePoint Today!Boost the Performance of SharePoint Today!
Boost the Performance of SharePoint Today!Brian Culver
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1sqlserver.co.il
 
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...Prolifics
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...Amazon Web Services
 
Work with hundred of hot terabytes in JVMs
Work with hundred of hot terabytes in JVMsWork with hundred of hot terabytes in JVMs
Work with hundred of hot terabytes in JVMsMalin Weiss
 
(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool ManagementBIOVIA
 
Cloud Design Patterns - Hong Kong Codeaholics
Cloud Design Patterns - Hong Kong CodeaholicsCloud Design Patterns - Hong Kong Codeaholics
Cloud Design Patterns - Hong Kong CodeaholicsTaswar Bhatti
 
Benchmarking Performance and Scalability with Web Stress
Benchmarking Performance and Scalability with Web StressBenchmarking Performance and Scalability with Web Stress
Benchmarking Performance and Scalability with Web StressInterSystems Corporation
 
SPSUtah 2014 SharePoint 2013 Performance (Admin)
SPSUtah 2014 SharePoint 2013 Performance (Admin)SPSUtah 2014 SharePoint 2013 Performance (Admin)
SPSUtah 2014 SharePoint 2013 Performance (Admin)Brian Culver
 

Similaire à Caching up is hard to do: Improving your Web Services' Performance (20)

Performance and Scalability Tuning
Performance and Scalability TuningPerformance and Scalability Tuning
Performance and Scalability Tuning
 
Configuring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceConfiguring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web Perormance
 
Expect the unexpected: Prepare for failures in microservices
Expect the unexpected: Prepare for failures in microservicesExpect the unexpected: Prepare for failures in microservices
Expect the unexpected: Prepare for failures in microservices
 
Content Devilery Network
Content Devilery NetworkContent Devilery Network
Content Devilery Network
 
Building & Testing Scalable Rails Applications
Building & Testing Scalable Rails ApplicationsBuilding & Testing Scalable Rails Applications
Building & Testing Scalable Rails Applications
 
Scalability and performance for e commerce
Scalability and performance for e commerceScalability and performance for e commerce
Scalability and performance for e commerce
 
IBM Maximo Performance Tuning
IBM Maximo Performance TuningIBM Maximo Performance Tuning
IBM Maximo Performance Tuning
 
SQL Server ASYNC_NETWORK_IO Wait Type Explained
SQL Server ASYNC_NETWORK_IO Wait Type ExplainedSQL Server ASYNC_NETWORK_IO Wait Type Explained
SQL Server ASYNC_NETWORK_IO Wait Type Explained
 
Caching
CachingCaching
Caching
 
Resilience planning and how the empire strikes back
Resilience planning and how the empire strikes backResilience planning and how the empire strikes back
Resilience planning and how the empire strikes back
 
Boost the Performance of SharePoint Today!
Boost the Performance of SharePoint Today!Boost the Performance of SharePoint Today!
Boost the Performance of SharePoint Today!
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1
 
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
 
Work with hundred of hot terabytes in JVMs
Work with hundred of hot terabytes in JVMsWork with hundred of hot terabytes in JVMs
Work with hundred of hot terabytes in JVMs
 
(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management
 
Web Performance Optimization (WPO)
Web Performance Optimization (WPO)Web Performance Optimization (WPO)
Web Performance Optimization (WPO)
 
Cloud Design Patterns - Hong Kong Codeaholics
Cloud Design Patterns - Hong Kong CodeaholicsCloud Design Patterns - Hong Kong Codeaholics
Cloud Design Patterns - Hong Kong Codeaholics
 
Benchmarking Performance and Scalability with Web Stress
Benchmarking Performance and Scalability with Web StressBenchmarking Performance and Scalability with Web Stress
Benchmarking Performance and Scalability with Web Stress
 
SPSUtah 2014 SharePoint 2013 Performance (Admin)
SPSUtah 2014 SharePoint 2013 Performance (Admin)SPSUtah 2014 SharePoint 2013 Performance (Admin)
SPSUtah 2014 SharePoint 2013 Performance (Admin)
 

Plus de RTigger

Give your web apps some backbone
Give your web apps some backboneGive your web apps some backbone
Give your web apps some backboneRTigger
 
Hackers, hackathons, and you
Hackers, hackathons, and youHackers, hackathons, and you
Hackers, hackathons, and youRTigger
 
AJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side TemplatesAJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side TemplatesRTigger
 
JavaScript!
JavaScript!JavaScript!
JavaScript!RTigger
 
Parallel Processing
Parallel ProcessingParallel Processing
Parallel ProcessingRTigger
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive ExtensionsRTigger
 
Sql vs NoSQL
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQLRTigger
 
Git’in Jiggy With Git
Git’in Jiggy With GitGit’in Jiggy With Git
Git’in Jiggy With GitRTigger
 
What The F#
What The F#What The F#
What The F#RTigger
 
Web Services
Web ServicesWeb Services
Web ServicesRTigger
 
Total Engagement
Total EngagementTotal Engagement
Total EngagementRTigger
 

Plus de RTigger (12)

Give your web apps some backbone
Give your web apps some backboneGive your web apps some backbone
Give your web apps some backbone
 
Hackers, hackathons, and you
Hackers, hackathons, and youHackers, hackathons, and you
Hackers, hackathons, and you
 
AJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side TemplatesAJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side Templates
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
 
Parallel Processing
Parallel ProcessingParallel Processing
Parallel Processing
 
Node.js
Node.jsNode.js
Node.js
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive Extensions
 
Sql vs NoSQL
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQL
 
Git’in Jiggy With Git
Git’in Jiggy With GitGit’in Jiggy With Git
Git’in Jiggy With Git
 
What The F#
What The F#What The F#
What The F#
 
Web Services
Web ServicesWeb Services
Web Services
 
Total Engagement
Total EngagementTotal Engagement
Total Engagement
 

Dernier

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Dernier (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Caching up is hard to do: Improving your Web Services' Performance

  • 1. Caching Up is Hard To Do Chad McCallum ASP.NET MVP iQmetrix Software www.rtigger.com - @ChadEmm Improving the performance of your web services
  • 2. Here’s your API Client makes a request Bounces around the internet to web server Web server runs application, queries DB Database returns data from query Application serializes response and writes to client Bounces back through internet to client Client receives data Client The Internet Web Server Database
  • 3. An example request Client The Internet Web Server Database Client makes a request Bounces around the internet to web server Web server runs application, queries DB Database returns data from query Application serializes response and writes to client Bounces back through internet to client Client receives data 270ms 598ms3474ms 4342ms 528kb
  • 4. Start at the data • Optimize the database server • Logical Design – efficient queries, application-specific schema, constraints, normalization • Physical Design – indexes, table & system settings, partitions, denormalization • Hardware – SSDs, RAM, CPU, Network
  • 5. Between your App and the Data • Reduce the complexity of your calls – get only the data you need • Reduce the number of calls – return all the required data in one query • Make calls async – perform multiple queries at the same time* • The fastest query is the one you never make • Cache the result of common queries in an application-level or shared cache 598ms 315ms 47% Application Time
  • 6. Caching Data • Great for static or relatively unchanged data • Product Catalogs • Order History • Not so great for volatile data • Store Quantity • Messages • Comes with a memory price • Shared Cache when working with a web farm
  • 7. Inside your App • Standard “MVC” Flow • Request comes into Web Server over network connection • Framework parses request URL and other variables to determine which controller and method to execute, checking against routes • Framework creates instance of controller class and passes copy of request object to appropriate method • Method executes, returning an object to be sent in response • Framework serializes response object into preferred type as requested by client • Web server writes response back to client over network connection
  • 8. Inside your App • The most we can reasonably do is optimize our controller’s method • “Reasonably” meaning not doing crazy things to the underlying framework code / dependencies • The fastest method is one you don’t execute • Cache the serialized result of common API calls 598ms 296ms 51% Application Time
  • 9. Caching Responses • Great for endpoints that don’t take parameters • Get • Not so great for endpoints that do take parameters • Get By ID • reports with date ranges • Get with filters • Cache all supported serialization formats • Same cache concerns – memory usage, shared cache in farm setup
  • 10. From Server to Client • We can’t really change the topology of a client’s network connection • We can send less data • HTTP Compression 3474ms 1083ms 69% 528kb 129kb 76% Response Size Response Time
  • 11. HTTP Compression • Trading response size for server CPU cycles • Output can be cached (and often is) by web server to avoid re- compressing the same thing • Client requests compression using Accept-Encoding header 598ms 624ms 4% Application Time
  • 12. Paging • Don’t send everything! • Only returning 20 items • Page objects using OData Queries in WebAPI • Returning IEnumerable<T> will page in-memory • Returning IQueryable<T> will (attempt to) page at the database layer 3474ms 7ms 99.8% 528kb 10kb 98.1% Response Size Response Time
  • 13. Conditional Headers • Server can send either an ETag and/or Last-Modified header with response • ETag = identifier for a specific version of a resource • Last-Modified = the last time this resource was modified • Clients can include that data in subsequent requests • If-None-Match: “etag value” • If-Modified-Since: (http date) • Server can respond with a simple “304 Not Modified” response
  • 14. Conditional Headers 3474ms <1 ms 99.9% 528kb 0.3kb 99.9% • Avoid database calls to validate requests • Cache last modified times & etag values • May have to modify client code to retain and send Last-Modified and ETag values • Most browsers will automatically include If-Modified-Since, but some do not include If-None-Match • Non-browser code (SDKs, WebClient, HttpClient) Response Size Response Time 598ms 323ms 54% Application Time
  • 15. Client-Side Caching • Most browsers have a local cache – tell your clients to use it! • Expires header tells client how long it can reuse a response • Expires: Thu, 03 Apr 2014 03:19:37 GMT • Cache-Control: max-age=## (where ## is seconds) header does the same, but applies to more than just the client cache… • In either case it’s up to the client whether it uses the cache or not • Most browsers cache aggressively
  • 16. Intermediate Caching • Cache-Control header specifies who can cache, what they can cache, and how things can be cached • Public / Private – whether a response can be reused for all requests, or is specific to a certain user • max-age – the longest a response can be cached in seconds (overrides Expires header) • must-revalidate – if the response expires, must revalidate it with the server before using it again • no-cache – must check with the server first before returning a cached response
  • 17. Client-Side Caching • Great for static or relatively static data • Static HTML, JS, CSS files, or read-only lists of data that rarely change • Not so great for dynamic or mission-critical data • Hard to force clients to get latest version of data when they don’t even talk to the server • If you have to update before Expires or Max-Age runs out, you’ve got a problem 4342ms 100ms 97.7% Response Time
  • 18. Review • Optimize your database for your application • Cache on the server • Common database calls • Serialized results • Send less data • HTTP Compression • Paging • Conditional Headers / 304 Not Modified • Cache on the client • Expires and Cache-Control headers

Notes de l'éditeur

  1. - Before animations, show “standard” endpoint code- Note on “bounces around to web server” – that’s about 8 hops from my home network to our azure instance in East Asia
  2. Mention the cool new in memory OLTP / tables and compiled stored procedures in SQL Server 2014
  3. You can return multiple result sets in one query – it takes some manual tweaking of the EDMX file and/or extra code in Entity Framework, but it is possibleKeep in mind high traffic + async can result in database overloadAfter last point, show call to cached-db endpoint
  4. Shared cache like memcached or a faster? database call (i.e. nosql, in memory table, etc)
  5. Show applicationhost.config transform, make request with Accept-Encoding: gzip header