QNimate

  • CoursesVideos
  • WP PremiumPlugins
  • DemosLab
  • Bitcoin BankingBuy, Sell, Store and Earn Interest
  • Home
  • QIdea
  • QTrack
Home Carbon Ads Redis Permanent Storage

Redis Permanent Storage

Redis is a in-memory storage system. Primary memory is volatile i.e., data is lost when we restart our computer. Some people want to use redis just like an DBMS which keeps its data stored permanently. Redis does provide some mechanism to make the data persistance(permanent).

There are three different ways to make Redis persistant: RDB, AOF and SAVE command.

  1. RDB Mechanism: RDB makes a copy of all the data in memory and stores them in secondary storage(permanent storage). This happens in a specified interval. If your computer restarts due to power failure then there is chance that you will loose data that are set after RDB’s last snapshot.
  2. AOF: AOF logs all the write operations received by the server. Therefore everything is persistance. The problem with using AOF is that it writes to disk for every operation and it is a expensive task and also size of AOF file is large than RDB file.
  3. SAVE Command: You can force redis server to create a RDB snapshot anytime using the redis console client SAVE command.

You can use AOF and RDB together to get best persistance result.

Setting Up Data Persistance

If you can live with few hours/minutes of data loss then its always better to only use RDB mechanism only. By default redis.conf file is enabled to make the dataset save every minute into a file named as dump.rdb. You can also manually trigger the SAVE command anytime to dump latest dataset into the dump.rdb file.

If every single bit of data is important then you should use AOF mechanism. By default AOF is disabled. To enable it go to your redis.conf file and edit

appendonly yes

Now redis will append all operations into a file called as appendonly.aof. Redis has internal mechanism to clean this file regularly. The size of this file will never exceed your filesystem size because harddisk always has more space then primary memory. Redis puts everything into appendonly.aof that has been put in the primary memory. This logic is same for dump.rdb file also.

Its recommend that if you are using AOF then you should also use RDB. Don’t use AOF alone. There are little chances for appendonly.conf file corruption as log files tend to be corrupted sometimes. When you are using AOF and RDB together redis automatically manages them to reduce filesystem write overwhelming.

For more information of Redis persistance refer this official documentation.

Sep 19, 2014Narayan Prusty
Storing Binary Data in RedisRetrieving Social Shares, Likes And Comments Count Of A URL

Leave a Reply Cancel reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

Narayan Prusty

I am a full-stack web developer. I specialize in Blockchain and JavaScript. This is my personal blog where I write about programming and technologies that I learn and feel interesting to share.

6 years ago Databases
Share this
0
GooglePlus
0
Facebook
0
Twitter
0
Linkedin
Related Articles
  • Storing Binary Data in Redis
  • Overview Of Redis Architecture
  • MySQL Architecture For Large Websites
  • Storing Binary Files in Redis
  • Storing Image in Redis
Our Sponsor
Freelance: I am available
@narayanprusty
Hi, I am a full-stack developer - focusing on JavaScript, WordPress, Blockchain, DevOps, Serverless and Cordova. You can outsource your app development to me.





Will get back to you soon!!!
WordPress
ReactJS
Meteor
Blockchain
Serverless
Kubernetes
DevOps
DB & Storage
Ejabberd
Let's get started
My Books

2014 - 2015 © QNimate
All tutorials MIT license