Tag Info

Hot answers tagged

9

Is unanswerable, except to say it depends. There are a lot of factors which will determine which approach is going to be the best in your case, e.g.: Is it normal for created objects to be retrieved shortly after they are created? What's the ratio of updates to accesses? Re. deciding you need a cache: If you're optimising without data then yes, it's ...


6

My recommendation is to look at your usage profile and your requirements for the cache. I can see no reason why you would leave stale data in memcached. I think you have picked the right approach ie: update the DB. In any case, you're going to need a wrapper on your DB update (which you've done). Your code to update the User in the DB and in-RAM should ...


4

Client 1 connects, checks for an active lock on key 1, finds none, and gets the data You should not test for lock then create it, but rather attempt to create it with Memcache::add, which will either create lock or fail. It does so atomically, so you'll no longer have TOCTTOU race condition. $mc= new Memcache; $mc->connect('localhost', 11211); ...


3

For caching a straight dump of a single already-loaded object, yes, you gain nothing or next-to-nothing. That's not what those examples are describing - they're describing a hierarchy, where any change to something lower should also trigger an update to everything higher up in the hierarchy. The first example, from the 37signals blog, uses Project -> ...


2

I wouldn't go about it quite like you outlined. What you need to do is decide whether you actually NEED completely up-to-date data. Then, if you do need it, decide which parts of the data need to be up-to-date at all times and separate them from things that can be cached in your architecture. For example, you probably want to update your user's email ...


2

There are two parts to this story: memcached servers and libmemcached clients. Memcached servers are indeed independent of each other. Memcached server is just an efficient key-value store implemented as in-memory hash table. What makes memcached distributed is the client, which in most implementations can connect to a pool of servers. Typical ...


2

A lot of how you handle this problem is going to hinge on that requirement of 100% of the customers being served. When the goal is absolutely no downtime then performance will almost always have to take a second position to reliability. You say that your timespan for a typical response is a matter of milliseconds but how do you want to handle the situation ...


2

These days, being a web developer doing both front and backend will be pretty hard for a beginner. Javascript is taking over the web development world, meaning that the frontend side is not just about "writing some jquery". 80% of the frontend will be doable with abit of declarative jquery, never the less this is a bad way of coding. Several js frameworks ...


1

To put the things simple. Use Redis and you will never speak of memcache again. Following are some plus points: First of all in Redis you get the option to persist data in the disk. Second, you have data structures like list, set etc. Also, supports atomic operations.


1

Memcached is just a cache. The out of box java version at https://code.google.com/p/quickcached/ supports writing to disk on exit but for what you need, I think you will have to add your own code. One thing to consider is how much of data, at peak load do you think you will have 3 years from today? If that is not too much can use your own RAM with a in ...


1

Remember that RAM is volatile and if the server has to reset then that data would be lost. This sounds like it would be a concern, as you say you have to serve 100% of customers. I would recommend writing your own buffering system which keeps data in RAM but writes it to disk after a small delay. If the data is served within this time then there is no ...


1

memcached manages objects with its own policy, which cached object would expire if no one accesses it or the memcached run out of memory. Therefore, your first approach is not a good idea as your object in memcached would keep being invalidated due to out-of-memory when you are creating objects. Q1. Approach 2 would be better in terms of performance ...


1

If you deal with more than a handful of servers, you need some sort of configuration management/automation, even if it is a glorified multiplexed ssh client. Once you have that in place, most systems have a "apply this on this set of servers now" operation, which you can use for instance to tweak your web server configuration and restart it (to enable a ...



Only top voted, non community-wiki answers of a minimum length are eligible