Question

I am thinking to create a web app, my web host charges me according to how many times I do persistence in database if I do persistence after every CRUDoperation that will cost me too much, I am thinking of a solution that if I store data temporarily in ArrayLists or HashMaps and schedule my persistence i.e. persist after every 30mins or 1hour, will that work ? and if so then what would be maximum time, time after that should I need to persist my Collection so that I achieve less persistence in database.

Was it helpful?

Solution

I think this is basically a bad approach. Don't design your web app for your web host.

persist after every 30mins or 1hour

Such a design can cause you so many headaches in the future. Think about what will happen to the modifications when the app crashes (for whatever reason, imagine a power outage).

On the other hand, from performance perspective, it can be useful to cache entities, see e.g.: http://memcached.org/

OTHER TIPS

It will work, but at what cost.

What happens if you lose the data stored in memory, how much will that cost you? How will it affect the users of your application? What about scalability?

In reality, are there so many operations that you can't perform the required database transactions at the point they should be done. If you get to a point where you are doing more transactions, would this not mean that you have more customers, and therefore can pay more.

My advice is this would be extremely bad practice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top