impactrudia / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
0 stars 0 forks source link

MemcacheService should be replaced with AsyncMemcacheService with timeout on get request #183

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. wait for bad day at Google, when memcache service will work but it will work 
extremly slow
2. try to do get of cached entity, it will take up to 3s for single get, 
because of slow request to memcache

What is the expected output? What do you see instead?
Expected behaviour should be fallback after x ms (100-200ms) of memcache not 
returning anything back to requesting datastore. Instead we wait for 3s or even 
more to get single entity.

What version of the product are you using? On what operating system?
We are using objectify 3 and also 4, same problem. Problem accures only on 
Google App Engine when their memcache is working slow.

MemcacheService should be replaced with AsyncMemcacheService which offeres get 
with timeout, like this:

AsyncMemcacheService service = MemcacheServiceFactory.getAsyncMemcacheService();
if (service != null) {
        try {
                Future<Object> response = service.get(key);
                return response.get(500, TimeUnit.MILLISECONDS);
         } catch (InvalidValueException ive) {
                log.warning("Serialization error: \n" + ive.getMessage());
                return null;
         } catch (MemcacheServiceException | InterruptedException | ExecutionException | TimeoutException e) {
                log.warning("MemcacheServiceException: " + e.getMessage());
                return null;
         }
 }

Original issue reported on code.google.com by d...@black.si on 18 Dec 2013 at 1:05