Google Cloud Platform Blog
Product updates, customer stories, and tips and tricks on Google Cloud Platform
Best practices for App Engine: memcache and eventual vs. strong consistency
December 17, 2013
We have published two new articles about best practices for App Engine. Are you aware of the best ways to keep Memcache and Datastore in sync? The article
Best Practices for App Engine Memcache
discusses concurrency, performanceand migration with Memcache to make you aware of potential pitfalls and to help you build more robust code.
Do you know how to make your App Engine application faster and more scalable by using eventual consistency? If not, take a look at a
new article
that explains the difference between eventual and strong consistency. The paper will help you leverage Datastore to scale your apps to millions of happy customers.
Concurrency, performance and migration in memcache
Memcache is a cache service for App Engine applications that is shared by multiple frontend instances and requests. It provides in-memory, temporary storage that is intended primarily as a cache for rapid retrieval of data that's backed by some form of persistent storage, such as Google Cloud Datastore.
Using Memcache will speed up your application's response to requests and reduce hits to the datastore (which in turn saves you money). However, keeping Memcache data synchronized with data in the persistent storage can be challenging when multiple clients modify the application data.
Transactional data sources, such as relational databases or Google Cloud Datastore, coordinate concurrent access by multiple clients. However, Memcache is not transactional, and there's a chance that two clients will simultaneously modify the same piece of data in Memcache. As a result, the data stored may be incorrect. Concurrency problems can be hard to detect because often they do not appear until the application is under load from many users.
With App Engine, you can use the “compare and set” (Client.cas()) function to coordinate concurrent access to memcache. However, if your application uses the compare and set function, it must be prepared to do the error handling and retry.
We recommend that you use the atomic Memcache functions where possible, including incr() and decr(), and use the cas() function for coordinating concurrent access. Use the Python NDB API if the application uses Memcache as a way to optimize reading and writing to Google Cloud Datastore. Read more
Best Practices for App Engine Memcache
in our newly published paper.
Balancing strong and eventual consistency
Web applications that require high-scalability often use NoSQL which offers eventual consistency for improved scalability. However, if you're used to the strong consistency that relational databases offer, it can be a bit of a mind shift to get your head around the eventual consistency of NoSQL data stores. Google Datastore allows you to choose between strong and eventual consistency, balancing the strengths of each.
Traditional relational databases provide strong consistency of their data, also called immediate consistency. This means that data viewed immediately after an update will be consistent for all observers of the entity. Use cases that require strong consistency include knowing “whether or not a user finished the billing process” or “the number of points a game player earned during a battle session.” It also means that all requests to view the updated data are blocked until all the writes required for strong consistency have finished.
Eventual consistency, on the other hand, means that all reads of the entity will eventually return the last updated value but might return inconsistent views of the data in the meantime. For example, knowing “who in your buddy list is online” or “how many users have +1’d your post” are cases where strong consistency is not required. Your application can get higher scalability and performance by leveraging eventual consistency, because your application won't have to wait for all the writes to complete before returning results.
The following two diagrams illustrate strong versus eventual consistency:
Eventual conistency
Strong consistency
To learn more about the differences between eventual and strong consistency and to learn how to take advantage of each read our
article
on the technical solutions portal at
cloud.google.com/resources
.
-Posted by Alex Amies, Cloud Solutions Technical Account Manager
No comments :
Post a Comment
Free Trial
Labels
Android
Announcement
api
app engine
Atmosphere Live
bigquery
BigTable
CDN
Cloud Console
Cloud Dataflow
Cloud Datastore
cloud endpoints
Cloud Pub/Sub
Cloud SDK
cloud sql
cloud storage
Cloudera
Compute
Compute Engine
container cluster
customer
Dev Tools
developer tools
developer-insights
Developers
Developers Console
devfests
Disaster Recovery
Encryption Keys
ESG
Event
events
GA
Go Client
Google App Engine
Google Apps
Google BigQuery
Google Cloud Deployment Manager
Google Cloud Networking
Google Cloud Platform
Google Cloud Storage
Google Compute Engine
Google Container Engine
gRPC
hadoop
Hardware
Helium
how to
IO2013
iOS
Kubernetes
Levyx
Local SSD
mapreduce
Media
Nearline
networking
open source
PaaS Solution
Partner
Pricing
Research
round-up
Server
Siggraph
solutions
Startup
Tableau
TCO
Technical
Windows
Wowza
Zync
Archive
2015
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2014
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2013
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2012
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2011
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2010
Dec
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2009
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2008
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Feed
Technical questions? Check us out on
Stack Overflow
.
Subscribe to
our monthly newsletter
.
Follow @googlecloud
No comments :
Post a Comment