• Keine Ergebnisse gefunden

is a micro-benchmark modeled after a social networking scenario (500 operations per sec-ond, 90% reads, 10% writes, navigational access with sporadic queries and transactions).

There were three consecutive runs for different sizes of the database comparing Orestes exposing VOD against VOD with its binary TCP protocol.

Figure 3.12a shows that the average execution time of the test is heavily reduced with Orestes. The performance improvements are not only a consequence of the applied web caching. The ability of the Orestes unified interface to combine different operations in a single round-trip, makes network communication significantly more effective in high-latency environments. For example, by batching a transaction commit into a single HTTP request, multiple round-trips can be saved.

Figure 3.12b reports the results of the same micro-benchmark for a setup of hardware machines using a single client, different caches (both in Hamburg) accessing Orestes/VOD (California). The results show that the large performance advantage is consistent across different web caches. This is a consequence of Orestes relying on standard HTTP caching.

Furthermore, the experiments also show that Orestes without any caching is competitive to custom database protocols. For detailed results in this setting, we refer to [GBR14] as well as the evaluations discussed in Chapter 4.

Due to the low overhead and efficient communication of updates in Orestes, even without any caching, the overall performance of Orestes is roughly 30% better compared to VOD’s native protocol. Thus, the overall performance of REST/HTTP as the only interface of Orestes, does not impose a substantial overhead. Any latency optimization achieved by Orestes therefore directly improves performance over native database protocols.

tack-les query processing and concurrency control in a database-agnostic middleware. Thus, these features are available irrespective of the individual databases’ capabilities. In par-ticular, real-time queries enable users to subscribe to specific queries and optimistic ACID transactions introduce strong guarantees for interleaved multi-object modifications.

The Orestes architecture offers a universal DBaaS/BaaS environment that we utilize to obtain our core contribution of latency reduction in cloud data management as described in the following chapter.

4 Web Caching for Cloud Data Man-agement

This chapter introduces a cache coherence scheme for dynamic data to significantly reduce latency on the web. The approach leverages traditional web caching technology and en-hances it with the capability to keep data up-to-date in real time on a global scale. Fresh-ness is particularly challenging in cloud data management, as data tends to be volatile and may change at any time. For this reason, we introduce means to expose fine-grained trade-offs between the desired latency and the guaranteed consistency levels for applica-tions. This approach enables data-driven web applications and mobile apps that rely on cloud-hosted data and are still able to achieve imperceptible response times.

First, we will introduce theCache Sketch data structure that allows Orestes to transfer the task of maintaining cache coherence from the server to the client. Using the Cache Sketch, we enable end devices to keep expiration-based caches up-to-date with very lit-tle overhead. The strategy is complemented by proactive updates to invalidation-based caches executed by the DBaaS/BaaS. The Cache Sketch enables several tunable consis-tency levels for caching objects and files. The key guarantee is ∆-atomicity that bounds staleness and exposes∆as a parameter that can be chosen per request, session, or appli-cation.

Based on the construction of the Cache Sketch, we extend the caching scheme to support dynamic query results. To this end, changes to query results have to be detected in real time. To enable high cache hit rates and low space overhead, we proposeTTL Estimation as a mechanism to determine the approximate time until a cached query result becomes stale. To minimize the number of round-trips to assemble a query result, we introduce an analytic model that determines the best encoding of results for a given access pattern.

To solve the problem of high abort rates for optimistic transactions, we propose Dis-tributed, Cache-Aware Transactions (DCAT). DCAT exploits our caching scheme to lower the overall transaction execution time and significantly reduces aborts. This allows appli-cations to fall back to the strong guarantees of ACID transactions when the guarantees of the Cache Sketch alone are insufficient.

We provide evidence for the performance improvements through both Monte Carlo simu-lation and experimental evaluation. For typical workloads on the web, the Cache Sketch

approach can improve performance by an order of magnitude and therefore is a major step towards a web without loading times.

4.1 Cache Sketches: Bounding Staleness through Expiring Bloom Filters

In this section, we introduce the Cache Sketch methodology that employs automatic caching of database objects and files requested through a REST/HTTP API. As motivated in Chapter 2, latency for cloud services is an open challenge that can currently not be addressed through web caching, as expiration-based models offer insufficient consistency guarantees for data management. Subsequently in Section 4.4, we extend this approach from object and file caching to query result caching.

We achieve cache coherence through a dual approach: expiration-based web caches (browser/device caches, forward proxy caches, ISP caches) are kept consistent through client-side revalidations enabled by the Cache Sketch data structure, whereas invalidation-based web caches are updated by purge requests issued by the database service. The proposed caching methodology is applicable to any data-serving cloud service, but par-ticularly well-suited for DBaaS and BaaS systems. The Cache Sketch is a Bloom filter of potentially stale objects maintained in the database service. To determine whether an ob-ject can safely be fetched from caches, clients query the Cache Sketch before reads. If the object’s ID is contained in the Cache Sketch, a revalidation request is sent, as intermediate caches might hold a stale copy. The issued HTTP revalidation request instructs caches to check whether the database object has a different version than the locally cached copy. If a false positive occurs, a harmless revalidation on a non-stale object is performed, which has performance implications comparable to those of a cache miss.

Clients leverage the Cache Sketch for three different goals: fast application and session starts (cached initialization), cached reads with consistency guarantees (bounded stale-ness), and low-latency transactions (distributed cache-aware transactions). Forcached ini-tialization, clients transparently store every fetched object in the client cache (usually the browser cache). At the begin of a new session or page visit, the Cache Sketch is trans-ferred, so clients can check which cached copies from the last session are still up-to-date.

The number of necessary requests is thus reduced to the cache miss ratio of intermediate caches. To maintain∆-bounded staleness, the Cache Sketch is refreshed in intervals of ∆.

The interval constitutes a controllable upper bound on the staleness of loaded objects.

Similarly,distributed cache-aware transactionsload the Cache Sketch at transaction begin.

Subsequent transactional reads exploit cached objects, reducing the overall duration and associated abort probability of the transaction.

By optimistically caching all objects and employing the Cache Sketch to only revalidate stale objects, almost the same cache hit ratio is achieved as if the time to the next write was known in advance. An object can only be removed from the Cache Sketch once

it is known to have been expired in all caches. Thus, precise estimations of expiration times impact cache hit ratios after writes as well as the number of necessary invalidations.

To tune the inherent trade-off between cache hits, stale reads, invalidations, and false positives towards a given preference, we present theConstrained Adaptive TTL Estimator (CATE) that complements the Cache Sketch by adjusting cache expirations to optimize the trade-off.

This section covers three central contributions:

• We propose theCache Sketchas a data structure that enables the use of expiration-and invalidation-based web caching for cloud data management systems to combine the latency benefits of caching with rich consistency guarantees.

• We describe the Constrained Adaptive TTL Estimation (CATE) algorithm that com-putes object expiration dates to minimize stale read probabilities and invalidations while maximizing cache hits.

• We present the Monte Carlo caching simulation Framework YCSB wrapper for Monte Carlo simulation (YMCA) that allows to analyze and optimize caching strategies and Cache Sketch parameters for pluggable network, database, and caching topologies.

In the following, we first present the Cache Sketch with its properties and effects. Next, we outline the TTL estimation problem and a possible solution. Afterwards, we introduce the YMCA simulation framework and present simulated and empirical results for the proposed combination of web caching and cloud data management.

4.1.1 The Cache Sketch Scheme

The expiration-based caching model of HTTP was deliberately designed for scalability and simplicity. It therefore lacks cache coherence protocols and assumes a static TTL (time to live) which indicates the time span for which a resource is valid, allowing every cache to keep a copy. This model works well for immutable content, for example a particular version of a JavaScript library. With the rise of REST APIs for cloud services, however, this model fails in its naive form – TTLs of dynamic content, in particular database objects and query results are not known in advance. This has led to database interfaces that forbid caching in the first place as staleness would be uncontrollable otherwise (cf. Section 2.3.3).

Figure 4.1 shows an architectural overview of how our Cache Sketch approach addresses this problem. Every cache in the request path serves cached database objects requested by their respective keys to the client, which can either be an end user’s browser, a mobile application, or an application server. The Bloom filter of the client Cache Sketch is queried to send a request either as normal request (object not contained) or a revalidation (object contained). The revalidation forces caches to update their copy using an HTTP request conditioned over the object’s version (ETag).

Client

Expiration-based Caches

Invalidation-based Caches

Server Cache Sketch Staleness- MinimizationInvalidation- Minimization

10201040 10101010

Counting Bloom Filter Non-expired

Object Keys Request

Path

Server/DB Invalidations,

Objects Report Expirations and Writes

Needs Invalidation?

Client Cache Sketch

at connect

Periodic every Δ seconds

at transaction begin Cache

Hits

10101010 Bloom filter Needs Revalidation?

Browser Caches, Forward Proxies, ISP Caches

Content Delivery Networks, Reverse Proxies

1

2 3

4

Cached

Initialization 2 Δ-Bounded Staleness

1

3 Distributed

Cache-Aware Transactions 4 Invalidation Minimization Figure 4.1: Architectural overview of the client and server Cache Sketch.

The database service tracks the highest TTLs per resource provided at a cache miss. On a subsequent write, the object is added to a Counting Bloom filter [BM03] of the server Cache Sketch and removed when the object’s TTL is expired. The database service is furthermore responsible for purging objects from invalidation-based caches (CDNs and reverse proxy caches), which allows them to answer revalidations. To minimize invali-dation broadcasts, purges are only sent, if the server Cache Sketch reports an object as non-expired. It is important to note, that this scheme does not require any modifications of the HTTP protocol or web cache behavior. The proposed Cache Sketch approach is further not specific to a particular database service architecture and can be realized either directly in the nodes of database system or as a tier of stateless REST servers exposing the database. We chose the latter approach by building on Orestes as described in detail in Chapter 3.

There are several advantages of caching database objects close to clients:

• Cache hits have lower latencyand higher throughput than uncached requests, as TCP throughput is inversely proportional to round-trip time [Gri13].

• The database service is under lighter load, as it only has to handle write requests and cache misses.

• Clients profit from requests of other clients, as all caches except the browser/device cache are shared and thus increaseread scalability.

Flash crowds, i.e., load spikes caused by unexpected and sudden popularity, are mitigated by caching and do not bring down the database service [FFM04].

Temporary unavailabilityof the database service can be compensated for reads by letting CDNs and reverse proxies serve cached objects while the service is unreach-able.

4.1.2 The Client Cache Sketch

For each potentially non-expired, cached objectx, the client Cache Sketch has to contain its keykey(x). For now, we will only consider key/ID lookups – the most common access pattern in key-value, document, and wide-column stores – and discuss how the scheme can be extended to query results in the following section. The client Cache Sketch is based on Bloom filters, as they satisfy several properties that are central to our requirement for efficient detection of potentially stale objects:

Additions and Removals in Server, Lookups in Client. The server needs the ability to add and remove potentially stale objects from the Cache Sketch, whereas the client needs to check for containment. The Bloom filter with its extension to counting offers these operations for the client and server, respectively [FCAB00].

Fast Client-Side Lookups. The Bloom filter supportsO(1) lookups and thus is very effi-cient for clients to be queried as an in-memory data structure for any read.

Small Size. As the client Cache Sketch needs to be transferred often, its size should be as small as possible. Bloom filters are within a factor of 1.44 of the theoretical lower bound of required space for a given false positive rate [BM03].

No False Negatives. Any false negative for a Cache Sketch lookup would entail an in-consistent read with unbounded staleness. Therefore, false negatives must be pre-vented, which is the case for Bloom filters. Occasional false positives, on the other hand, are permissible, as they only impact latency (cache misses) and not correct-ness.

Generation in Constant Time. To scale with the number of clients, fetching the Cache Sketch should not impose any computation overhead in the server, but instead corre-spond to a constant-time in-memory dump of a data structure. This can be achieved with Bloom filters, as described in the following section.

According to Broder et al. [BM03] the concept of using Bloom filters for sets, when space requirements are of high importance and false positives can be tolerated, is known as the Bloom filter Principle (cf. [BM03]). A Bloom filter is a space-efficient encoding of a set and is based on bit vectors and hash functions. Bloom filters were developed in 1970 by Burton Bloom [Blo70] as a memory-efficient data structure for hyphenation programs.

The idea is to query a word to determine whether it is suitable for rule-based hyphenation,

like 90% of all English words, or whether it needs to be looked up in a dictionary on hard disk. Memory efficiency is critical to maintaining the data structure in main memory, while the negative side-effect of a false-positive is negligible (the lookup of a word from disk in Bloom’s original setting). Bloom filters have since been used for a wide variety of database problems [BM03, FCAB00]. In the last 10 years, their usefulness has been discovered for many other areas such as collaboration, routing, and data analysis [TRL12].

We only cover aspects of Bloom filters and probabilistic data structures that are relevant to our approach and refer to the comprehensive treatment of their mathematical properties by Broder et al. [BM03] for details. A discussion and comparison to alternative data structures for the Cache Sketch is provided in Section 6.1.4.

k hash functions m Bloom filter bits

1 0 0 1 1 0 1 1

h1

hk

...

key

find(key) Bits = 1

Client Cache Sketch

no yes

GET request

Revalidation

Cache Hit

Miss

key

key

Figure 4.2: Database read using the Cache Sketch.

As shown in Figure 4.2, a read on a key is performed by querying the Bloom filterbt of the client Cache Sketchct that was generated at time t. A Bloom filter represents a set

S=key1,key2,...,keyn withn elements through a bit array of lengthm. The key is hashed

usingk independent uniformly distributed hash functions that map from the key domain to [1,m], where m is the bit array size of bt. If all bits h1(key), . . . ,hk(key) equal 1, the object is contained and has to be considered stale. Thus, false positives can occur: if all positions of a key have been set to 1 by inserting other keys, it is wrongly recognized as being contained. Orestes abstracts from this by transparently performing the lookup for each client-side load and query operation and automatically refreshes the Cache Sketch according to the desired consistency level.

4.1.3 Proof of∆-Atomicity

Theorem 4.1 deducts the central guarantee offered by the Cache Sketch using the time-based consistency property ∆-atomicity [GLS11] (cf. Chapter 2). ∆-atomic semantics assert that every value becomes visible during the first∆time units after the acknowledg-ment of its write.

Theorem 4.1. Let ct3 be the client Cache Sketch generated at time t3, containing the key key(x)of every objectxthat was written before it expired in all caches, i.e., everyxfor which holds that∃r(x,t1,T T L),w(x,t2):t1+T T L>t3>t2>t1. The readr(x,t1,T T L)is a cache miss onxat timet1, whereT T L is the time to live provided for that read andw(x,t2) is a write on xat timet2 happening after the read.

A read on objectxperformed at timet4usingct3 satisfies∆-atomicity with∆=t4−t3, i.e., the read is guaranteed to see only objects that are at mosttime units stale.

Proof. Consider there was a read issued at timet4 which used the latest Cache Sketchct3 and that returned an objectxthat was stale for∆>t4−t3which would violate∆-atomicity.

This implies that x must have been written at a time t2<t3 as otherwise ∆<t4−t3 (∆-atomicity no violated). Forxto be stale, there must have been a previous readr(x,t1,T T L) witht1+T T L>t4>t2 so thatxwas still cached in at the time of the stale read. However, by the construction ofct3 the object’s key is contained inct3 untilt1+T T L. Therefore, the read att4<t1+T T Lusingct3 could not have been stale (proof by contradiction).

t1

r(x) TTL

t2

w(x)

t3

ct3

t4

Δ r(x)

t1 + TTL Retrieved

Cache Sketch Staleness

Bound

timespan for which x ∈ c

Figure 4.3: Illustration of the proof of∆-atomicity for the Cache Sketch.

Theorem 4.1 states that clients can tune the desired degree of consistency by controlling the age∆of the Cache Sketch: the age directly defines∆-atomicity. The proof with its used variables is illustrated in Figure 4.3 that shows the different operations and timestamps.

The guarantee relies on the linearizability of the underlying database system, i.e., writes are assumed to be directly visible to uncached reads. If the database is only eventually consistent with∆db-atomicity, the guarantee is weakened to(∆+∆db)-atomicity1. Similarly, if the invalidation-based caches only support asynchronous invalidations (which is typical for real-world CDNs [PB08]) with∆c-atomicity, the consistency guarantee becomes (∆+

c)-atomicity2.

If ∆c is either unbounded or an undesired source of uncertainty, ∆-atomicity can be es-tablished in two ways. First, invalidation-based caches can be treated as pure expiration-based caches by not letting them answer revalidation requests. The trade-off is that this increases read latency and the load on the database service. Second, invalidations can be performed synchronously. This is a good option for reverse proxy caches located in the

net-1Bailis et al. [BVF+12] have extensively studied the staleness of Dynamo-style systems. They found that with high probabilitydbis very low (in the order of single-digit milliseconds) and for many configurations not perceivable at all.

2We are not aware of any scientific studies on CDN purge latencies. Anecdotally, the Fastly CDN used in our evaluations employs the bimodal multicast protocol for invalidations with measured latencies typically much lower than 200ms [Spa17].

work of the database service. Here, the trade-off is that cache misses have higher latency and can be blocked by the unavailability of a cache node (no partition tolerance).

4.1.4 Controlling Consistency

Definition 4.1 introduces three client-driven age-control techniques for the Cache Sketch.

Cached initialization builds on the insight that initially ∆=0 for a Cache Sketch piggy-backed upon connection. This implies that every cached object can be used without de-grading consistency, i.e., loading the Cache Sketch is at least as fresh as loading all initially required objects in bulk, which may also include all static resources (images, scripts, etc.) of the application or website.

Definition 4.1. A client followscached initialization, if all initial reads are performed using a freshly loaded Cache Sketchct. A read attnowfollows∆-bounded staleness, if it only usesct

iftnow<t+∆. Adistributed cache-aware transactionstarted attsusescts for transactional reads.

∆-bounded staleness guarantees ∆-atomicity by not letting the age of the Cache Sketch exceed ∆. Updates may be performed eagerly or lazily. With eager updates, the client updatesct in intervals of∆. As this may incur updates despite the absence of an actual workload, lazy updates only fetch a new Cache Sketch on demand. To this end, if a read request is issued attnow>t+∆, the request is turned into a revalidation instructing the service to append the Cache Sketch to the result. Hence, at the mild cost of a cache miss at most every∆time units,ct is updated without additional requests.

Similar to cached initialization, a distributed cache-aware transaction (DCAT) is started by loading the Cache Sketch3. The caching model is only compatible with optimistic transactions as reads are performed in caches which cannot participate in a lock-based concurrency control scheme. By having clients collect the read sets of their transactions consisting of object IDs and version numbers, the database service can realize the trans-action validation using BOCC+, as described in Section 4.8. The important alteration that DCAT brings to this scheme is that cached reads can drastically reduce the duration T of the transaction, while the Cache Sketch limits staleness during transaction execu-tion. Since the abort probability of optimistic transactions quickly grows withT [Tho98], loweringT through cache hits can greatly reduce abort rates.

Figure 4.4 shows an end-to-end example of Cache Sketch usage, in which a client reads two different objectsx3 and x2 first and then updates a third object x1. First, the client fetches the Cache Sketch (step 1). Then,x3is loaded which is not contained in the Cache Sketch and therefore requested normally, resulting in a cache hit (step 2). Next, the client readsx2which is contained and hence a revalidation is sent, causing the expiration-based cache to evict its cached copy (step 3). The server returnsx2 with a new TTL/expiration

3Transactions could potentially start by reusing an already available Cache Sketch, however this increases stale reads that always lead to an abort.

4. The client writes object x1.

3. The client revalidates object x2 from the server.

2. The client reads object x3 from the cache.

1. The client connects to the server and retrieves a Bloom filter b.

Client Expiration

Cache Invalidation

Cache Server

Client Cache

Sketch Server Cache

Sketch

b={x2} t = {(x2, t2),(x1, t1)}

b=∅

b={x2}

Connect bt0={x2}

Query x2

Response inv=true c={(x2,t2),(x3,t3)} c={(x1,t1)}

Revalidate x2

c={(x3,t3)}

Response x2,t4

c={(x2,t4),(x3,t3)} c={(x1,t1),(x2,t4)}

Report Read x2,t4

Put

x1=v Report Write

x1 b={x2,x1} t = {(x2, t4),(x1, t1)}

Response ok

Invalidate x1

Response true Query

x3

Response

false Get

x3

Response x3

b={x2} t = {(x2, t4),(x1, t1)}

Figure 4.4: An end-to-end example of the proposed Cache Sketch methodology.

datet4, which is saved in both invalidation-based and expiration-based caches. Addition-ally, the new expiration date is also reported to the server Cache Sketch, where expiration state is tracked. On the subsequent write on x1, it is added to Counting Bloom filter of the server Cache Sketch, since its expiration datet1has not yet passed (step 3). This also tells the server to invalidate the object in invalidation-based caches. Any later readers are therefore able to revalidatex1from an invalidation-based cache.

As discrepancies between actual and estimated TTLs can cause extended periods for which objects are contained in the Cache Sketch and considered stale, clients perform a differen-tial whitelisting: every object that has been revalidated since the last Cache Sketch update is added to a whitelist and considered fresh until the next Cache Sketch renewal4. While

4This assumes that all requests by a client pass through the same set of caches, which is true for most networks and TLS-encrypted connections.

Im Dokument Low Latency for Cloud Data Management (Seite 134-149)