Redis Start Process Introduction _redis

Source: Internet
Author: User
Tags redis

1. Prepare to run the environment

* Set Oom Handler,zmalloc allocated memory failed to call
* Initialize random seeds to generate random numbers
* Initialize server parameters to default values
* Create a mapping table for commands and processing functions

2. Parse the command-line arguments, Loadserverconfig () resolve the configuration file

* The configuration file overwrites the parameters specified by the command line
* Invalid configuration item or unreasonable configuration value will cause Redis to not start properly

3. Initserver () initialization service

* Install signal processing function
* Create shared objects, Redis commonly used objects for sharing to save memory
* Adjust Max open files according to MAXC lients configuration
* Create a global DB dictionary, each db corresponds to a dict
* Monitor network ports, install event handlers
* If AoF is turned on, open aof file
* Create Servercron Timer

4. Loaddatafromdisk () loading data from RDB or aof files

* Load data error (such as file format confusion) and so on will cause Redis can not start normally
* In the process of loading, Redis can still process the request, but most requests will reply-loading error

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

The event handler function that listens for the file descriptor is initialized to Accepttcphandler, and the newly established connection's event handler function is set to readqueryfromclient,readqueryfromclient read requests from the network connection. Resolves the request parameters and processes them.

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.