Cloud World

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Tuesday, 17 December 2013

Best practices for App Engine: memcache and eventual vs. strong consistency

Posted on 12:00 by Unknown
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
Email ThisBlogThis!Share to XShare to Facebook
Posted in app engine | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Bridging Mobile Backend as a Service to Enterprise Systems with Google App Engine and Kinvey
    The following post was contributed by Ivan Stoyanov , VP of Engineering for Kinvey, a mobile Backend as a Service provider and Google Cloud ...
  • Tutorial: Adding a cloud backend to your application with Android Studio
    Android Studio lets you easily add a cloud backend to your application, right from your IDE. A backend allows you to implement functionality...
  • 2013 Year in review: topping 100,000 requests-per-second
    2013 was a busy year for Google Cloud Platform. Watch this space: each day, a different Googler who works on Cloud Platform will be sharing ...
  • Easy Performance Profiling with Appstats
    Since App Engine debuted 2 years ago, we’ve written extensively about best practices for writing scalable apps on App Engine. We make writ...
  • TweetDeck and Google App Engine: A Match Made in the Cloud
    I'm Reza and work in London, UK for a startup called TweetDeck . Our vision is to develop the best tools to manage and filter real time ...
  • Scaling with the Kindle Fire
    Today’s blog post comes to us from Greg Bayer of Pulse , a popular news reading application for iPhone, iPad and Android devices. Pulse has ...
  • Who's at Google I/O: Mojo Helpdesk
    This post is part of Who's at Google I/O , a series of guest blog posts written by developers who are appearing in the Developer Sandbox...
  • A Day in the Cloud, new articles on scaling, and fresh open source projects for App Engine
    The latest release of Python SDK 1.2.3, which introduced the Task Queue API and integrated support for Django 1.0, may have received a lot ...
  • SendGrid gives App Engine developers a simple way of sending transactional email
    Today’s guest post is from Adam DuVander, Developer Communications Director at SendGrid. SendGrid is a cloud-based email service that deliv...
  • Qubole helps you run Hadoop on Google Compute Engine
    This guest post comes form Praveen Seluka, Software Engineer at Qubole, a leading provider of Hadoop-as-a-service.  Qubole is a leading pr...

Categories

  • 1.1.2
  • agile
  • android
  • Announcements
  • api
  • app engine
  • appengine
  • batch
  • bicycle
  • bigquery
  • canoe
  • casestudy
  • cloud
  • Cloud Datastore
  • cloud endpoints
  • cloud sql
  • cloud storage
  • cloud-storage
  • community
  • Compute Engine
  • conferences
  • customer
  • datastore
  • delete
  • developer days
  • developer-insights
  • devfests
  • django
  • email
  • entity group
  • events
  • getting started
  • google
  • googlenew
  • gps
  • green
  • Guest Blog
  • hadoop
  • html5
  • index
  • io2010
  • IO2013
  • java
  • kaazing
  • location
  • mapreduce
  • norex
  • open source
  • partner
  • payment
  • paypal
  • pipeline
  • put
  • python
  • rental
  • research project
  • solutions
  • support
  • sustainability
  • taskqueue
  • technical
  • toolkit
  • twilio
  • video
  • websockets
  • workflows

Blog Archive

  • ▼  2013 (143)
    • ▼  December (33)
      • 2013 Year in review: topping 100,000 requests-per-...
      • 2013 Year in review: making Google Compute Engine ...
      • 2013 Year in review: bringing App Engine to the PH...
      • Now Get Programmatic Access to your Billing Data W...
      • 2013 year in review: making scalability easy with ...
      • 2013 Year in review: taking Google Cloud Platform ...
      • 2013 Year in review: pushing the limits of Big Data
      • 2013 Year in review: enabling native connections f...
      • 2013 Year in review: bringing Offline Disk Import ...
      • Best practices for App Engine: memcache and eventu...
      • 2013 Year in review: giving time back to developers
      • 2013 Year in review: bringing together mobile and ...
      • Go on App Engine: tools, tests, and concurrency
      • Qubole helps you run Hadoop on Google Compute Engine
      • Alert Logic security and compliance solutions for ...
      • Outfit 7’s Talking Friends built on Google App Eng...
      • You can now deliver any-screen streaming media usi...
      • Using Google Compute Engine with open source software
      • DataTorrent offers massive-scale, real-time stream...
      • DataStax Enterprise feels right at home in Google ...
      • Why We Deployed Zencoder on Google Cloud Platform
      • Scalr and Google Compute Engine
      • Cloud9 IDE on Google Compute Engine
      • Fishlabs architects upcoming game with Compute Eng...
      • An ode to Sharkon
      • SaltStack for Google Compute Engine
      • Google Compute Engine and App Engine give Evite fr...
      • SUSE Linux Enterprise Server Now Available on Goog...
      • Google Compute Engine is now Generally Available w...
      • The new Persistent Disk - faster, cheaper and more...
      • Red Hat and Google Compute Engine – Extending the ...
      • Google Compute Engine helps Mendelics diagnose gen...
      • CoolaData digs into the “why” of online consumer b...
    • ►  November (15)
    • ►  October (17)
    • ►  September (13)
    • ►  August (4)
    • ►  July (15)
    • ►  June (12)
    • ►  May (15)
    • ►  April (4)
    • ►  March (4)
    • ►  February (9)
    • ►  January (2)
  • ►  2012 (43)
    • ►  December (2)
    • ►  November (2)
    • ►  October (8)
    • ►  September (2)
    • ►  August (3)
    • ►  July (4)
    • ►  June (2)
    • ►  May (3)
    • ►  April (4)
    • ►  March (5)
    • ►  February (3)
    • ►  January (5)
  • ►  2011 (46)
    • ►  December (3)
    • ►  November (4)
    • ►  October (4)
    • ►  September (5)
    • ►  August (3)
    • ►  July (4)
    • ►  June (3)
    • ►  May (8)
    • ►  April (2)
    • ►  March (5)
    • ►  February (3)
    • ►  January (2)
  • ►  2010 (38)
    • ►  December (2)
    • ►  October (2)
    • ►  September (1)
    • ►  August (5)
    • ►  July (5)
    • ►  June (6)
    • ►  May (3)
    • ►  April (5)
    • ►  March (5)
    • ►  February (2)
    • ►  January (2)
  • ►  2009 (47)
    • ►  December (4)
    • ►  November (3)
    • ►  October (6)
    • ►  September (5)
    • ►  August (3)
    • ►  July (3)
    • ►  June (4)
    • ►  May (3)
    • ►  April (5)
    • ►  March (3)
    • ►  February (7)
    • ►  January (1)
  • ►  2008 (46)
    • ►  December (4)
    • ►  November (3)
    • ►  October (10)
    • ►  September (5)
    • ►  August (6)
    • ►  July (4)
    • ►  June (2)
    • ►  May (5)
    • ►  April (7)
Powered by Blogger.

About Me

Unknown
View my complete profile