views:

133

answers:

2

I am building a webapp that has the following characteristics:

  1. It only has a small number of pages, home,contact us, about,singup,etc.
  2. Each user has one jquery-based page that allows them to drag/drop/manipulate DOM elements.
  3. When a user has finished manipulating elements they can hit Save and elements are sent via JSON to a PHP script on the server. They can also Load previously saved JSON.

So essentially: very few pages with 90% static information. One page with client-side work and potentially a lot of GETting/POSTing of JSON.

I have built a POC of this using PHP/Smarty, jQuery and mySQL. User details are stored in mySQL and so is the JSON data. Webpages are cached by Smarty on disk.

Now I'm thinking about scalability and the obvious question is should I be storing the often-changed JSON data in mySQL or should I be using memcacheDB or some other key-value store? Would you go for the easy mySQL option or introduce a key-value store now or would you wait to see if scale issue arise? Am I realistically ever going to reach a point where mySQL is the bottleneck?

I'm planning to host this on Slicehost to begin with and then move it if need be.

+1  A: 

As far as the JSON is concerned, it won't make a difference: I don't see how you can optimize the storage of that data. I think the question boils down to "How complex is the user data?". If there's a massive social graph connected with RDBMS foreign keys, and it's too difficult to map that data to a key-value store, I'd rather not expend the effort now. However, if the user data is just flat profile information, I'd rather move to a key-value store now, than later, before I use too many RDBMS features.

Ramkumar Ramachandra
Thanks for the response. I'm always going to have user data in mySQL - it's just simple profiles. My main concern was whether storage+retrieval of strings containing the JSON objects would be quicker using key/value store.
Steve Claridge
Hm. I haven't thought about that hard enough- I was focused more on user profile data. You could try profiling... with plain JSON strings, I'm not sure why the key-value store should be significantly faster.
Ramkumar Ramachandra
+1  A: 

Question is, would there be any lookups based on these values or not? Is there going to be updates for specific values at database level or not... Serilaized data or json is going to be faster and more efficient(storage wise) if all you do is pull the entire string and have no requirements to query or modify it.

Based on how you scale though, you may want to keep a key/value structure along with a flat data representation for lookup purpose.

Also consider using apache AB for some benchmarking and getting ideas on how your changes effect your concurrent output.

Good luck :)

Mohammad
No lookups, just straight storage. Generate JSON using jQuery, store as-is in mySQL and then later retrieve from DB, send back to client-side and jQuery iterates over JSON.
Steve Claridge
Then straight saving of JSON is going to be the least process usage and better storage model. (even though it may take more space to hold, but will leave you with fewer rows in the table to deal with, hence, smaller index file and faster retrieves).
Mohammad