Introduction to the Redis startup process

Source: Internet
Author: User

Reproduced in: http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/114.html?1455860562

1. Preparing the operating environment

* Set Oom Handler?,zmalloc When allocating memory fails when calling
* Initialize random seeds to generate random numbers
* Initialize the server parameter to the default value
* Create a mapping table for command and handler functions

2. Parsing the command line arguments, Loadserverconfig () parsing the configuration file

* The configuration file overrides the parameters specified by the command line
* Invalid configuration items or unreasonable configuration values will cause Redis to not start properly

3. Initserver () initialization service

* Install signal processing function
* Create shared objects, Redis pre-allocates common objects for sharing to save memory
* Adjust Max open files according to MAXC lients configuration
* Create a global db dictionary with one dict per db
* Monitor network port, install event handler
* If AoF is turned on, open the AoF file
* Create Servercron Timer

4. Loaddatafromdisk () load data from an RDB or aof file

* Failure of the load data (e.g., file format) will cause Redis to not start properly
* Loading process, Redis can still process requests, but most requests will reply-loading error

5. Aemain () Start event loop, receive client request

The event handler function for the listener file descriptor is initialized to Accepttcphandler, and the newly established Connection event handler is set to Readqueryfromclient,readqueryfromclient to read the request from the network connection. Resolves the request parameters and processes them.

Introduction to the Redis startup process

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.