My hosting provider offers me to increase my server's memory from 8gb to 24gb, at the same monthly cost of 3x 120gb SSD.
SSD choice seems more reasonable to me; but im curious if my web application will need in-memory caching after it's running on SSD.
Thanks.
The question you should ask when choosing between RAM and SSD is, "How much does my application really need to use the disk?"
If you have an application that is mostly scripts doing computation and sending custom versions of pages to users and handling the same kind of requests over not very much data over and over again, then RAM is what you need.
If, however, you are running a file server, streaming media, or thrashing random files that won't fit in RAM, the extra speed given by an SSD will help you a lot. Another place you'll see a good payoff for SSDs is if the application does a lot of writes. SSDs typically have much better read than write performance, but they are still much faster than platter drives.
Where I work, we have an application that writes several GB of data over tens of thousands of RRDs every few minutes. Upgrading the server to one with a fast SSD improved performance dramatically. The same probably could not be said for the server that handles, say, the authentication database. Although that database is large, queries on it are frequently similar (same people logging into the same apps over and over), so caching in RAM is much more beneficial.
Basically, if you're serving the same requests over and over, go for RAM. The OS will cache the data you use frequently and you'll see good performance. If you're application does a lot of IO to "random" files, you'll be thrashing the cache and will see more benefit from a fast SSD.
Flash SSD's (which I take it we're talking about here) are fast but they are no substitute for RAM. Typical server RAM bandwidth is measured in many-gigabytes/sec and latencies for read and and write are in the low nanosecond range - the sort of flash based SSD's you are looking at have bandwidth in the hundreds of megabyte/sec range at best and latencies in the microsecond range.
It may make no difference for your app if there are other factors involved but any data access from SSD's will still be a couple of orders of magnitude slower than reading it directly from RAM.
It may still need caching. You will be running 24GB of memory how much storage? If your having performance issues memory helps but it might also be the volume or location that your applications caching is storing its space.
You need to do performance measuring of your existing system to find out where the bottlenecks are.
Let's assume you don't have any significant bottlenecks (bad assumption, by the way). The question is, do you want 24G of blazing fast reads, disk speed writes, or 120G of pretty fast reads and writes. If you have more than 24G of data to serve, or it changes frequently, then you want the SSDs.
On the other hand, if you only have 10G of static data to serve, and your server process takes only 2G of RAM, then you can put your document root on a RAM disk with 24G of RAM and walk away.
If there are bottlenecks (swap, disk I/O reading bandwidth, disk I/O writing bandwidth, I/O operations per second) then you need to address those specifically. Both options can help, but which is better depends on the situation.