Ric Goell Ming Lei Web Cache Oracle Corporation

28

description

Ric Goell Ming Lei Web Cache Oracle Corporation. Web Caching for Database Centric Applications. Outline. Part I - Introduction to Web Caching Part II - Designing with Caching in Mind A process for analyzing the potential for caching benefits Part III – Partial Page Caching with ESI - PowerPoint PPT Presentation

Transcript of Ric Goell Ming Lei Web Cache Oracle Corporation

Page 1: Ric Goell Ming Lei Web Cache Oracle Corporation
Page 2: Ric Goell Ming Lei Web Cache Oracle Corporation

Ric GoellMing LeiWeb CacheOracle Corporation

Page 3: Ric Goell Ming Lei Web Cache Oracle Corporation

Web Caching for Database CentricApplications

Page 4: Ric Goell Ming Lei Web Cache Oracle Corporation

Outline• Part I - Introduction to Web Caching• Part II - Designing with Caching in Mind

– A process for analyzing the potential for caching benefits

• Part III – Partial Page Caching with ESI– Edge Side Includes (ESI) – a standards based

technology for page and fragment caching– JESI – A set of JSP tags that support ESI

Page 5: Ric Goell Ming Lei Web Cache Oracle Corporation

Part I Why Web Caching?

• Content is becoming more dynamic for a richer and more personal Web experience.

• The number of people using web based applications is growing beyond the limits of traditional infrastructures.

• User expectations are growing – they expect more relevant content and fast response times

• Large “Farms” are costly to purchase and manage

Page 6: Ric Goell Ming Lei Web Cache Oracle Corporation

Caching on the Web

Browser Cache

ForwardProxy

Internet/Intranet

Edge Servers

ReverseProxy

ApplicationServer

Database

Central Data CenterCDN/eCDN

$$ $$

$$$$

$$

$$ $$ $$

Page 7: Ric Goell Ming Lei Web Cache Oracle Corporation

E-Commerce PerformanceMeasuring response time isn't enough

0

200

400

600

8001000

1200

1400

1600

1800

2000

1 10 100 1000

Throughput in pages/sec

Res

po

nse

Tim

e in

ms

Webcache

Apache

Page 8: Ric Goell Ming Lei Web Cache Oracle Corporation

Cache Hit Rate

• Cache hits are practically freefree when compared to generating dynamic pages.

• Focus is on improving cache hit rates. 0

1000

2000

3000

4000

Throughput (Requests per second)

Web Cache EJB

Page 9: Ric Goell Ming Lei Web Cache Oracle Corporation

Why don’t more apps provide caching

• “But my pages have too much customization to be cacheable.”

• A lame excuse – new tools allow customized and dynamic content to be cached– Page fragments can be assembled– Request and Response Variables can be included– Cache Consistency tools to help with invalidation

Page 10: Ric Goell Ming Lei Web Cache Oracle Corporation

Part II: Designing with Caching in Mind

• A 3 Step Process– Page Analysis – Determining what to cache– Disambiguation – Key Generation– Cache Consistency – Removing items from

cache

Page 11: Ric Goell Ming Lei Web Cache Oracle Corporation

Page AnalysisWhen designing a page layout, define fragments with

similar cache policies – early in design process• When evaluating the benefit of caching pages or

fragments, each of the following should be considered:– Share-ability – How many users share this content?– Generation Cost – How computationally intensive is

the generation of this content?– Frequency – How many times will this content be

viewed (even within one user’s session) before it changes?

• Note that even user specific content may be desirable to cache if it accessed frequently

Page 12: Ric Goell Ming Lei Web Cache Oracle Corporation

Disambiguation – Cache Key Definition

Differentiating documents based on specific requests.• URLs• Post Body• HTTP Headers

– Cookies

• MVC Apps tend to have less information in the request. Heavy use of backend state can reduce Web Cache benefits.

Page 13: Ric Goell Ming Lei Web Cache Oracle Corporation

Consistency Management

• Expiration – Time Based

• Invalidation based – explicit message to cache servers to remove content from cache

• Validation Based– ETAG and GIMS (similar capabilities for

fragments)

• Don’t be unnecessarily restrictive

Page 14: Ric Goell Ming Lei Web Cache Oracle Corporation

Session State Management

• Web Sites often use session keys to track user state and identify data on the server side.

• Web Cache was designed to work with sessions by transparently allowing session establishment and updates.

• Additionally it was designed to allow for caching of documents that include sessions.

Page 15: Ric Goell Ming Lei Web Cache Oracle Corporation

Session Encoded URLs

Session Ahttp://store.oracle.com/cec/cstage?session_ID=33436

Session Bhttp://store.oracle.com/cec/cstage?session_ID=33437

Page 16: Ric Goell Ming Lei Web Cache Oracle Corporation

Part III PartialPage Caching & Content Assembly

• Edge Side Includes (ESI) – an XML-like markup language used to define

cacheable and non-cacheable content fragments

– a content invalidation protocol for cache consistency

• Edge Side Includes for Java (JESI)– a custom tag library to facilitate the use of ESI with

JSP applications

Page 17: Ric Goell Ming Lei Web Cache Oracle Corporation

Industry Support for ESIAn open specification.

ESI published as a W3C Note.

JESI submitted to JCP as JSR 128.

See www.esi.org for more info.

Page 18: Ric Goell Ming Lei Web Cache Oracle Corporation

Summary of JESI Tags

TagTag PurposePurpose

<jesi:include><jesi:include>

<jesi:control><jesi:control>

<jesi:template><jesi:template>

<jesi:fragment><jesi:fragment>

<jesi:codeblock><jesi:codeblock>

<jesi:personalize><jesi:personalize>

<jesi:invalidate><jesi:invalidate>

Used in a “template” page to indicate to the ESI processor how to assembe the fragments (the tag generates the <esi:include> tag.

Assign an attribute (e.g., expiration) to templates and fragments.

Used to contain the entire content of a JSP container page within its body.

Specify that a particular piece of code needs to be executed before any other fragment is executed.

Encapsulate individual content fragments within a JSP page.

Explicitly remove and/or expire selected objects cached in an ESI processor.

Insert personalized content into a page where the content is placed in cookies and inserted into the page by the ESI processor.

Page 19: Ric Goell Ming Lei Web Cache Oracle Corporation

JESI Personalization

The URL query string has the Personal Valuehttp://Machine:port/zyz?user_name=JaneJane

<HTML>Welcome to the Oracle Store

<jes:personalize name=”user_name”>

...</HTML>

Page 20: Ric Goell Ming Lei Web Cache Oracle Corporation

What is ESI?

Page 21: Ric Goell Ming Lei Web Cache Oracle Corporation

Why ESI?

• ESI is in production– Co-developed with Akamai and Oracle– IBM is also implementing ESI

• ESI is an open language– Maturing through real usage– W3c note

Page 22: Ric Goell Ming Lei Web Cache Oracle Corporation

ESI at a glance

• Templates and Fragments– include & inline

• Variables– Query String Variables– Cookie Variables– Environment Variables

• A good sample App:– http://otn.oracle.com/sample_code/products/ias/web_cache/htdocs/jesi/Readme.html

Page 23: Ric Goell Ming Lei Web Cache Oracle Corporation

ESI Personalization

The URL query string has the Personal Valuehttp://Machine:port/zyz?user_name=JaneJane

<HTML>Welcome to the Oracle Store<esi:vars> <esi:vars>

$(QUERY_STRING{'user_name'})! $(QUERY_STRING{'user_name'})!

</esi:vars></esi:vars>

...</HTML>

Page 24: Ric Goell Ming Lei Web Cache Oracle Corporation

<esi:include> Model

<html>...<esi:include

src=”/news101”>...</html>

/sample.html (template)

<table>...</table>

/news101

/sample.html

Cache Storage

Page Assembly

Cache Response

Template/news101

Page 25: Ric Goell Ming Lei Web Cache Oracle Corporation

<esi:environment>

...<esi:environment src=/stocks.xml

name=stock/>

...<esi:vars>ORCL $(stock{orcl_p}) $(stock{orcl_c}) YHOO $(stock{yhoo_p}) $(stock{yhoo_c}) </esi:vars>

...

/sample.html

/sample.html

Cache Storage

Page Assembly

Cache Response

Template/stocks.xml

<orcl_p>8.94</orcl_p><orcl_c>+0.09</orcl_c><yhoo_p>16.55</yhoo_p><yhoo_c>-0.46</yhoo_c>

/stocks.xml

Page 26: Ric Goell Ming Lei Web Cache Oracle Corporation

ESI - Storage & Assembly• Parsing is only done

the first time a page is fetched.

• A buffer array is generated for a scatter/gather network write

• This buffer is maintained in the cache for fast cache hits without page assembly processing

Template 1

Fragment 1

Fragment 2

Fragment 3

BufferArray

Page 27: Ric Goell Ming Lei Web Cache Oracle Corporation

ESI PerformanceThroughput

(Requests per second)

971

190

200

400

600

800

1000

1200

Web Cache Portal App

• This test measured a real portal application without Web Cache and ESI.

• Either the Portal App or Web Cache did the page assembly

• 10 portlets

Page 28: Ric Goell Ming Lei Web Cache Oracle Corporation

Other Interesting Web Cache Features / Topics

• Invalidation / Consistency Management– Expiration based– Invalidation based

• Clustering

• Cache Hierarchies