Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression...

38
Optimization

Transcript of Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression...

Page 1: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

Optimization

Page 2: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

HTTP Compression

Page 3: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Compression

• NetScaler supports various ways of compressing traffic

• HTTP traffic can easily be compressed by NetScalerᵒ Less work for the web serverᵒ Client can understand and de-compress (accept-encoding header)

• Compression governed via policies

• Preconfigured policies exist

Page 4: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Optimizing Compressible Content Delivery

• Improves “time to last byte”

• Current generation browsers support standardized compression algorithmsᵒ gzipᵒ deflateᵒ HTTP Header field: “Accept-Encoding: gzip,deflate”

• Text and some binary files are compressible

• GIFs and JPGs are not compressible

• Encrypted content is not compressible

Page 5: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Compression

• Benefits (mainly for dynamic content) ᵒ Reduced bandwidth consumptionᵒ Reduced end user latency

• Basics of Operationᵒ “Base” version of a file is stored in the NetScaler cache and browser cache. Called

“Basefile”ᵒ “Updated” version of the file is compared vs. the “Basefile” ᵒ Differences are transmitted, along with a scriptᵒ Differences are applied by the browser/javascript ᵒ “Policies” may be configured to select content to which this is applied

Page 6: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Browser Capability Probe

User

Server

Internet

Response with Javascript probe inserted

User Access the app first time

Response from the server

JavaScript probe creates delta cookie, if JS enabled

NetScaler

Page 7: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Initial Page Access Workflow

User

ServerIC

Internet

Response from the server as a Base file and first time response to the Client

FIRST TIME RESPONSE…<SCRIPT language=“javascript” src=“/nsdelta/delta.js”

First time response

Javascript Request, and Base File Request

Javascript Response,and Base File Response

Page 8: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Page Refresh Workflow

User

Server

NSCACHE

Internet

Netscaler calcualtes delta (File(update) – File(base) = delta File) and sends delta page to the client

Delta Response

User Access the page second time

Complete response from the serverJavascript decodes

the

delta received from the

Netscaler and displays.

Page 9: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Capabilities

• Supports HTML pages (content-type: text/html). All other content types are not supported (such as ppt, doc, pdf, js etc..)

• Supports HTTP GET and POST requests

• End-user browser must support JavaScript, Cookies, and Cache. NS probes the browser for JS/Cookie support before enabling Delta for that browser.ᵒ Tested with IE 6.x, Mozilla-based, Firefox.

• Browser should support GZIP (ie., browser should send accept-Encoding: Gzip or deflate).

Page 10: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Compression CLI commands

• > help set cmp parameterᵒ Usage: set cmp parameter [-cmpLevel <cmpLevel>]ᵒ [-quantumSize <positive_integer>] [-serverCmp ( ON | OFF )]ᵒ [-heurExpiry ( ON | OFF )] [-heurExpiryThres <positive_integer>]ᵒ [-heurExpiryHistWt <positive_integer>]

ᵒ where:ᵒ <cmpLevel> = ( optimal | bestspeed | bestcompression )

Page 11: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

SET CMP Parameter

• Quantumsize – cmp processing unit size

• Servercmp – allow compression at backendᵒ If disabled, NS will remove “Accept-encoding” header from request before sending to

server

• Heurexpiry, heurexpirythres, heurexpiryhistwtᵒ Heuristic expiry parametersᵒ Expiry can be verified through stat cmp output, which shows a “basefile requests

served” counter

Page 12: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Compression CLI Commands

• > show cmp parameterᵒ Configured compression parameters:ᵒ Compression level: optimalᵒ Quantum size: 57344ᵒ Server-side compression: OFFᵒ Heuristic basefile expiry: OFFᵒ Threshold ratio for heuristic expiry (100x): 100ᵒ History weightage for heuristic expiry: 50%ᵒ Done

Page 13: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Compression

• Compress 404 and 500 responsesᵒ They are likely to have ErrorDocuments

• Don't compress XML data for IE browserᵒ IE (older versions) has issues with compressed XML data

Page 14: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

Integrated Caching

Page 15: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Overview

Topics covered in the module include:

• Integrated Caching Architecture

• Static and Dynamic Content

• Request and Response Process Flow

• Cache Policies

• Cache Policy Evaluation

• Cache Content Groups

• Content Group Settings

Page 16: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Integrated Caching Architecture

Integrated caching:

• Stores frequently requested content in memory

• Intercepts all HTTP client requests and sends the response to the client if the response is stored in the integrated cache

• Can be configured in a reverse proxy architecture

• Comprises:ᵒ Content Groupsᵒ Cache Selectorsᵒ Policies

Page 17: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Reverse Proxy Integrated Caching Architecture

Data Center

BusinessPartners

Remote Employees

Customers

Suppliers

Telecommuters

Content Servers

Reverse ProxyCache

Citrix NetScaler

Page 18: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Content Groups and Policies

Cachepolicy

CacheObjects

Cacheselector

Contentgroup

NetScaler

Client requests

Response from cache

Cache misses sent to server

Origin ServerClient

Page 19: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Static and Dynamic Content

• Static content remains the same for multiple usersᵒ Page-based caching, such as search engine pages ᵒ Object-based caching, such as web-based application graphics

• Dynamic content periodically changesᵒ Object-based caching only, such as stock updates, sports scores and news

Page 20: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Static Content

Remote

Employees

Customers

Mobile Users

Suppliers/Partners

Cached Content

Multiple Requests

Single Request

Original Content

Gateway

Switch

Page 21: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Dynamic Content

Suppliers/Partners

MultipleRequests

Periodic Dynamic Refresh

Remote

Employees

Customers

Periodic Refresh

Gateway

Switch

Static

Content

Mobile Users

Cached

Content

Dynamic

Content

Page 22: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Request and Response Process Flow

• Integrated caching occurs early on in the request and response process flow

• The client request:ᵒ Hits or missesᵒ Undergoes request-side policy checking

• The server response:ᵒ Undergoes response-side policy checkingᵒ Goes through a CACHE or NOCACHE action

Page 23: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Overview of Processing Flow

Request-SidePolicy Checking

CACHE

HIT/MISS

Response-SidePolicy Checking

NOCACHE

Client Request

Server Response

Page 24: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

In Cache?

TestRequest-Side

Policies

Test DynamicInvalidation

Policies

Request Side

Match

Client

Request

No Match

Flush Invalid Content Group

HIT(Done)

NOCACHE MAY_NOCACHE

Yes

No

Expired content will be refreshed from

origin server

CACHE MAY_CACHE

Page 25: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Request SideMAY_NOCACHE?

Response Side

Yes

Server

Response

No Match

No

Match

CACHE

Test ResponseSlide Policies

RequestSide

NOCACHE?

NOCACHE

Yes

No

Page 26: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Cache Policies

• Cache policies:ᵒ Are request-side or response-sideᵒ Equal name + expression + actionᵒ Specify a content group in which to store the object ᵒ Are built-in or user-definedᵒ Must be bound to be active

• Available cache actions are:ᵒ CACHEᵒ NOCACHEᵒ MAY_NOCACHEᵒ MAY_CACHEᵒ INVAL

Page 27: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Cache Policy Evaluation

• Policies:

• Are evaluated in the order they are classified

• Operate with a first-match principle

• Have the response cached in the DEFAULT content group when the policies do not match

• Have request and response time processing

Page 28: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Making Graceful Configuration Changes

The following points contribute to creating graceful configuration changes:

• Integrated caching is always on unless disabled

• Reconfiguration done while the caching feature is enabled can lead to unexpected behavior

Page 29: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Cache Content Groups

• Cached objects are made a member of a content group

• Cache content groups can be created to organize content with like settings

• The following content group names are reserved:ᵒ DEFAULTᵒ ALL

Page 30: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Content Group Settings

Content group settings affect:

• Content aging

• Memory usage

• HTTP headers

• Cookie removal and other attributes

Page 31: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Setting Global Attributes

Some of the global attributes of caching include:

• ON | OFF

• Memory Limit (up to 50% of memory)

• Via

• Enable Bypass

Page 32: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Managing Caching

• Objects in cache can be invalidated by expiring or flushing

• Invalidations can be carried out at different levels of granularity:ᵒ Specific objectᵒ Specific content groupᵒ All content groups

• Cache status can be viewed in the command-line interface

Page 33: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Stat Cache Command

Page 34: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Caching Examples

Integrated caching examples include:

• Caching a news page

• Preventing caching of stock quotes

• Configuring an HTTP event-based expiry

Page 35: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Caching a News Page

A news page can be cached in the NetScaler integrated cache using the TTL configuration

add policy expression nytimes_dmn http.req.header("Host").contains("nytimes.com")

add cache contentgroup 10_min –relexpiry 600

add cache policy news_cache –rule “nytimes_dmn” –action CACHE –storeingroup 10_min

bind cache global news_cache –priority 100 –precedeDefRules YES

Page 36: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Preventing Caching of Stock Quotes

• Stock quotes cannot be cached because the price of shares varies at arbitrary intervals

add policy expression yahoo_quote_url http.req.url.contains("/d/quotes*")

add policy expression yahoo_quote_dmn http.req.header("Host").contains("finance.yahoo.com")

add cache policy yahoo_bypass –rule “yahoo_quote_url && yahoo_quote_dmn” –action NOCACHE

bind cache global yahoo_bypass –priority 10 –precedeDefRules YES

Page 37: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

© 2012 Citrix | Confidential – Do Not Distribute© 2012 Citrix | Confidential – Do Not Distribute

Configuring an HTTP Event-Based Expiry

A configuration example of an HTTP event-based expiry that flushes a specific cache group

add policy expression python http.req.url.contains("*.py")

add cache contentGroup py_group –relexpiry 300

add cache policy pyth_pol –rule python –action CACHE –storeingroup py_group

bind cache global pyth_pol -priority 100 -type REQ_OVERRIDE

add policy expression killer_python HTTP.REQ.URL.CONTAINS("flush.py") && CLIENT.IP.SRC.EQ(10.10.1.0)

add cache policy inval_pyth –rule killer_python –action INVAL –invalgroups py_group

bind cache global inval_pyth –priority 10 –type REQ_OVERRIDE

Page 38: Optimization. HTTP Compression © 2012 Citrix | Confidential – Do Not Distribute Compression NetScaler supports various ways of compressing traffic HTTP.

Work better. Live better.Work better. Live better.