RedBridge: RedisforHTTPAPI [recommended]

Source: Internet
Author: User
Tags download redis
RedBridge is an http api Based on redis. Use LUA to directly interact with redis. (Similar to database Stored Procedures) efficiently implement complex business logic. Project URL: code. google. compredbridge environment: Linux2.6 software author: Seven-night (Li jinxing) RedBridge has the following features: 1. Use C +

RedBridge is an http api Based on redis. Use LUA to directly interact with redis. (Similar to database Stored Procedures) efficiently implement complex business logic. Project Site: http://code.google.com/p/redbridge/ use environment: Linux 2.6 software author: seven night (Lee Jin Xing) RedBridge has the following features: 1. Use C +

RedBridge is an http api Based on redis. Use LUA to directly interact with redis. (Similar to database Stored Procedures) efficiently implement complex business logic.
Project URL: http://code.google.com/p/redbridge/
Environment: Linux 2.6
Software Author: seven nights (Li jinxing)

RedBridge has the following features:
1. Web servers written in C + epoll Support http get operations
2. Connection Pool and connection handle reuse improve connection efficiency with redis
3. Some class libraries use Redis code, which is more stable
4. Use LUA to directly call the Redis command to implement one-time Data Interaction and complex business logic. No need for multiple data interactions
5. Single-process and dual-thread Service Model
6. The configuration file adopts Lua syntax, which is easy to read and write.
7. There were no similar open-source projects before RedBridge was released

Installation documentation (the following installation documentation is provided by Diablo)

Lua: http://www.lua.org/download.html
Tcmalloc: http://code.google.com/p/google-perftools/
Redis needs this version with script for http://code.google.com/p/redis/downloads/detail? Name1_redis-2.2.111-scripting.tar.gz & can = 2 & q =
Redis internal execution lua code official blog article: http://antirez.com/post/redis-and-scripting.html

1. Download redis that supports LUA
Tar redis-2.2.111-scripting.tar.gz
Cd redis-2.2.111-scripting/src
Make
Make install
Redis-server/usr/local/src/redis-2.2.111-scripting/redis. conf redis Default Configuration File
Start redis-server/usr/local/redis. conf

2. LUA Installation
Tar-zxvf lua-5.1.4.tar.gz
Cd lua-5.1.4
Make prompt:
Please do
Make PLATFORM
Where PLATFORM is one of these:
Aix ansi bsd freebsd generic linux macosx mingw posix solaris
See INSTALL for complete instructions.
If the system PLATFORM name is in the supported list, if it exists, continue to run make PLATFORM. If it does not exist, directly run make generic.
Make generic
Make install
Test whether the LUA installation is successful.
Shell> lua
Print ('aaa ')
Aaa indicates success.

3. Install google-perftools
Tar-zxvf google-perftools-1.8.3.tar.gz
Cd google-perftools-1.8.3
./Configure prefixx =/usr/local/google-perftools/
Make
Make install

4. Install RedBridge
./Configure -- prefix = RedBridge installation directory -- tcmalloc = google-perftools installation directory -- lua = lua installation directory
Make
Make install

If no error is reported, the installation is successful.
Directory after installation
.
── Script (put the lua code here)
│ ── Read. lua (lua sample code)
── Redbridge
── RedBridge. lua (configuration file)

Procedure
1. redbridge parse the RedBridge. lua configuration file
2. Load the lua code file to the HashTable memory.
3. initialize the connection pool and establish several connections to the backend redis.

User Access Process


Case studies

Previously, he worked in a precision advertising company. Is to work with various portals to deliver advertisements, so the daily traffic is also large. Originally, the core of advertising was to adopt
Apache module, which regularly reloads advertising materials, serving conditions, and other data from mysql.
The core of this advertising system has the following problems:
1. apache module needs to write a large number of business logic C code (such as advertising based on page keywords, IP addresses, and other conditions) to make C code more complex. If the complete document is missing. It is difficult for others to take over the maintenance
2. The launch core needs to regularly reload data from MySQL.
3. The code structure is unclear. Difficult to maintain
4. Because of business needs, you often need to modify the business logic. Therefore, it is necessary to compile, deploy, and test repeatedly. Relatively troublesome

Benefits of using the new RedBridge Architecture

1. business logic and core code are separated. Make the code structure clearer
2. Because the business logic is implemented using lua, non-C developers can easily modify the lua code to change the business logic.
3. AD data and targeting conditions are stored in different data types of redis. When updating data in the background, PHP loads the data directly into redis. You do not need to regularly reload mysql Data.

Performance
According to the actual test by enthusiastic netizens "Diablo", it is higher than nginx + php and nodejs. Low memory usage and CPU resource usage

Summary
It is different from the Redis2NginxModule of agentzh. Redis2NginxModule executes the original redis command. RedBridge can use lua to directly call redis commands to implement complex business logic. It only needs one interaction.
Tags-redis, redbridge

Original article address: RedBridge: Redis for http api [recommended]. Thank you for sharing it with me.

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.