1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Redis vs MySql vs MongoDb vs File Cache for Data Caching?

Discussion in 'Databases' started by FutureKing, Jun 1, 2023.

?

Which solution is best for storing large of amount of Cache?

  1. Redis

    1 vote(s)
    100.0%
  2. MongoDB

    0 vote(s)
    0.0%
  3. MySql

    0 vote(s)
    0.0%
  4. Memcached

    0 vote(s)
    0.0%
  5. CouchDB

    0 vote(s)
    0.0%
  1. #1
    We are running many websites in Yii2 application. Currently we are using File Cache for Data Caching. Now we want to use load balancer and put our caching on dedicated server.
    We will have to store approx 100GB of cached data.

    What we have tried?

    File Cache: Working great currently. But We can not move it to seperate dedicated server.

    Redis Cache: We created a dedicated server for Redis. Since we are on low budget therefore instead of using 100GB RAM server we used 2Core CPU and 4GB RAM server and created Swap space of 110GB. for storing cached data. It worked great but after sometime there was a sudden spike in CPU usage to 100% and Redis crashed. This was started happening daily. I was unable to find the exact reason.

    Now I have two more options, using MongoDB as Cache server or Separate MySql Server for storing cached data.

    My question is to experienced developers is that if I use MongoDB or MySql as Cache Server will I get at least File Cache like performance? Currently I am ok with File Cache Performance, I only want to move my cache to separate server.
     
    FutureKing, Jun 1, 2023 IP
  2. laci272

    laci272 Well-Known Member

    Messages:
    163
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    118
    #2
    Your sudden spike in CPU was the swap. You should never swap in memory DB. MongoDB's cache is also in memory, and mongoDB is way worse than redis when in swaps, separate mysql is worse still.
    Redis is good, just not swap it and do not choose to store it's data on disk.
    As for 4 GB ram, check out contabo.com they have cheap options for 8-16 gb ram, but that means you need to move everything over to them... they are very much ok for the price.
    File cache is also ok, i would move the mysql to another server, and leave php and the file cache on the old one...
     
    laci272, Sep 18, 2023 IP