1

I want to minimize traffic/storage costs on GAE.

Users fill out a form, checking boxes to select options which are lines of text, eg "I wake up two or more times during the night." or "I sleep less than 7 hours per night." or "I usually have trouble falling asleep."

I want to store the user's selections using the datastore. I suppose I can save on storage space by giving each selection a unique identifier. Then I'll just store (for example) "342, 554, 106" instead of three long lines of text... Then retrieve those numbers and translate them back into sentences next time loading the page for each user.

My question is, will it be better to do that conversion on the client side, or the server side?

Obviously, doing the conversion on the client side will mean sending LESS data from client to server for storage - which is good. However, it would mean sending MORE data from server to client, considering the additional lines of client-side javascript necessary to facilitate the conversion, which they will be downloaded as part of the page source - and that could be bad.

monkey blot
  • 985
  • 3
  • 10
  • 18

2 Answers2

1

Sounds like you already figured out how best to store the data.

In terms of translating it to HTML on the server or client side, it'll depend on the complexity of your page. Analyzing it will probably be more time than it's worth, and it might change if your page changes. It's most likely a wash unless it's an extreme situation. Use whichever is simpler and get your project done and out the door. If you're using a framework that handles generating forms on the server side, use that. If you have hundreds of thousands of views and it's adding up to a significant cost, revisit the pages in particular that are causing you the problem.

An extreme situation might be if your form needs to appear many, many times on a page, in which case it may be easier to have the actual form in javascript once and reproduce it many many times.

dragonx
  • 14,963
  • 27
  • 44
0

Here are some suggestions:

  • Save the user preferences/settings on the Server too, so that you can have their preferences synced to multiple clients/devices in the future.
  • Having the data stored locally on the client is also recommended, so that the calls are not made to the server everytime to get some preferences. In offline situations, having the relevant data available locally within the client is very critical.

In terms of Storage options on GAE - there are various ones. Since you are using Datastore I suggest that you go with that. In terms of storage size of each entity and in/out bandwidth, it is something that you can calculate approximately and if you feel that you can achieve the same logic via a few numbers or combined number (in a single Datastore entity attribute) rather than multiple entity attributes, it is preferable and will help.

Romin
  • 8,708
  • 2
  • 24
  • 28