Google App Engine (Question about using Google app engine and Java)

116 views
Skip to first unread message

peter valencic

unread,
May 26, 2015, 8:04:11 AM5/26/15
to google-a...@googlegroups.com
Hi,this is my firs post on this group. 

I'am looking for some clarification about using google app engine with java. 
I have this kind of problem to resolve: (It's quite simple for me to do this in java and oracle database with oracle tables and triggers but in this case I must use only google APIs to do so)...


"You are responsible to implement a backend feature for new app. This feature is a internet site. It looks like this:
main point of feature is to notify users when one of their friends overtakes them in a game (lets say it has more experience) thus
each user might have friends (or it might not have) 
API call is made to backend each time user gains experience (assume you get this info)

if user has just overtaken some of his friends, a API call is made
to send him a notification (assume function to send notification exists)

if user is registered first time it gains experience API call is made to backend for each new friend user has added (or
removed)

Backend is implemented on Google App Engine (GAE) in Java language.
Describe how would you do the following:
1) use GAE services to store user data (user himself and friend list)
Where would you store user data? By what it would be indexed, based on
requirements/flow above?
Consider cost and performance (scaling).
2) GAE provides memcache service, how would you use it to minimize
reads from datastore (mamcache is free, datastore is not)
3) Product management has come up wiht new feature: friend size badge!
This is a feature that works like this:
10%
users with most friends get gold badge
top
30% get silver badge
top
50% get bronze badge
How would you change your design from question (1) to be able to
determine users badges in realtime (in API call handler)?"

Can someone drive me trough this case or give me some advice on this? 



Ryan (Cloud Platform Support)

unread,
May 26, 2015, 10:02:31 AM5/26/15
to google-a...@googlegroups.com, peterv...@gmail.com
Salutations Peter,

Welcome to the forms. There are many ways to do what you want to do. I will answer from my personal experience but you will need to adapt to your specific use case.

1) The user data I would store in the Datastore. It is designed to do such work. I would index the players login name / email. I would then have a repeated field that has a list of their friends. When the score is updated I would retrieve the list of friends and check their scores. To increase performance I would always do searches using key-only queries.

2) Memcache is great if you need information quickly but is not persistent. It can be flushed at anytime without warning. I would store username (key) and scores(value) in it and always check there before doing my checks in the datastore.

3) This one is tougher as you want % not fixed value. You need to have another datastore kind that would keep a running count. Counting entities in the datastore (when scaled up) is long and costly.  It is recommended to keep a running count. To keep the number of reads under control you need to manage when the list of badges is updated. I would update the list only when needed. Keep a datastore kind that has a list of thresholds. If someone adds a friend and it goes above the threshold update the badges. There are other options depending on how often the badges would be changing or how often they would be read.

Keep in mind this is how I would do it, others will have other ways that might match your use case better. These are recommendations based of my experience not a end all guide.

Jeff Schnitzer

unread,
May 26, 2015, 12:38:22 PM5/26/15
to Google App Engine, peterv...@gmail.com
This looks suspiciously like some sort of exam question.

Jeff

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/9ea486c9-9735-4dde-8864-e3a090c1d8f2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

peter valencic

unread,
May 26, 2015, 1:17:28 PM5/26/15
to Jeff Schnitzer, Google App Engine
Hi Jeff..

yes it's a kind of "expertise test" but I know how to develop it in Java and oracle db (local database where I can use table triggers, JPA and java).. or any kind of other database like (mysql or derbydb)..

The problem is that I don't have knowledge on Google Cloud services (which service to use to strore tables (bigQuery? any other options?)... (i.e if I use AWS there are elasticbeanstalk which is entire system with app container, database etc installed and ready to use / deploy war files)

Also what I don't understand is what are difference between memcache and datastore (point 2.)

For backend logic I can develop simple servlet or webservice (just for test purpose). 
Let's say i have two tables in mysql (local db).. What is the way to create the same tables on google cloud and use it with google  SDK in java?

I will try first to develop a simple service and deploy it on google cloud.. then I must know what means memchache and datastore (what are the difference and how to use them.. i will try to search also on youtube)..

but if someone has some good example please let me know
regards
PEter




Jeff Schnitzer

unread,
May 26, 2015, 2:46:05 PM5/26/15
to peter valencic, Google App Engine
You are at the bottom of a very long learning curve. You can surmount it but you need to start reading basic documentation for all of these components. When you understand the concepts, then it will be easy to answer those questions. Asking for direct answers to a test is inappropriate; we're not the ones being tested.

One conceptual disconnect I see is that you seem to be looking for tables. Neither the datastore nor memcache are sql databases nor do they work like sql databases, so stop thinking in terms of tables. Read the overview section for every piece, then read in-depth for the pieces that seem most appropriate.

Yes, it's going to take some time. But you want the expertise, right?

Jeff

peter valencic

unread,
May 26, 2015, 3:22:26 PM5/26/15
to Jeff Schnitzer, Google App Engine
Jap! 

Vinny P

unread,
May 28, 2015, 1:27:35 AM5/28/15
to google-a...@googlegroups.com
On Tue, May 26, 2015 at 12:17 PM, peter valencic <peterv...@gmail.com> wrote:
yes it's a kind of "expertise test" but I know how to develop it in Java and oracle db (local database where I can use table triggers, JPA and java).. or any kind of other database like (mysql or derbydb)..


I'm probably missing something here, but for the purposes of this question are you constrained to using the datastore? Your original requirements are quoted below (notice how it doesn't specify the choice of datastore/etc, it asks you where to store the user data):


On Tue, May 26, 2015 at 7:04 AM, peter valencic <peterv...@gmail.com> wrote:
Describe how would you do the following: 1) use GAE services to store user data (user himself and friend list)
Where would you store user data?


If you have free rein to choose the storage medium, pick Cloud SQL. It's basically MySQL in the cloud, and since you already claim experience in MySQL your knowledge is transferable. Bonus: the question about user badges is a relatively simple SQL statement away. Many GAE applications use Cloud SQL as their primary/only persistent data storage service.
 

On Tue, May 26, 2015 at 7:04 AM, peter valencic <peterv...@gmail.com> wrote:
Describe how would you do the following:
1) use GAE services to store user data (user himself and friend list) Where would you store user data?
2) GAE provides memcache service, how would you use it to minimize
reads from datastore (mamcache is free, datastore is not)


Here is where I have difficulty. In part (1) I apparently had free rein to choose whatever storage service I want, but in (2) I'm being constrained to the datastore. Yes, the deeper point of this question is how to save money by using memcache but I'm unclear if this is supposed to be a standalone question or if it builds upon (1)'s expected answer.
 

On Tue, May 26, 2015 at 1:45 PM, Jeff Schnitzer <je...@infohazard.org> wrote:
Yes, it's going to take some time.


I echo and +1 Jeff's comments.


-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com
 
Reply all
Reply to author
Forward
0 new messages