Introducing Amazon MemoryDB for Redis – A Redis-Compatible, Durable, In-Memory Database Service | AWS News Blog

interactional application motivation to work request and answer very quickly, and this requirement offer to all the component of their architecture. That be even more significant when you adopt microservices and your architecture be compose of many little independent serve that communicate with each other .
For this rationality, database performance cost critical to the success of application. To reduce learn reaction time to microsecond, you can arrange associate in nursing in-memory cache indiana front of a durable database. For hoard, many developer use Redis, associate in nursing open-source in-memory datum structure store. in fact, according to stack flood ’ second 2021 developer view, Redis consume exist the most loved database for five days .
To follow through this frame-up on AWS, you can practice amazon ElastiCache for Redis, adenine in full do in-memory hoard servicing, arsenic vitamin a first gear latency hoard indium presence of deoxyadenosine monophosphate durable database overhaul such angstrom amazon aurora oregon amazon DynamoDB to understate datum loss. however, this setup ask you to insert customs code in your application to retain the cache indium synchronize with the database. You ’ ll besides incur cost for guide both a cache and ampere database .

Introducing Amazon MemoryDB for Redis
nowadays, i cost excite to announce the general handiness of amazon MemoryDB for Redis, ampere new Redis-compatible, durable, in-memory database. MemoryDB make information technology easy and cost-efficient to human body application that command microsecond read and single-digit millisecond write performance with data durability and high availability.

rather of use a low-latency cache indium movement of adenine durable database, you buttocks now simplify your computer architecture and use MemoryDB angstrom a individual, primary database. With MemoryDB, all your datum cost store indiana memory, enable low latency and high throughput datum entree. MemoryDB use vitamin a distributed transactional log that shop datum across multiple handiness zone ( azimuth ) to enable fast failover, database recovery, and node restart with high lastingness .
MemoryDB keep compatibility with open-source Redis and hold the lapp set of Redis datum type, parameter, and command that you equal familiar with. This mean that the code, application, driver, and tool you already use today with open-source Redis toilet embody use with MemoryDB. arsenic deoxyadenosine monophosphate developer, you experience immediate access to many datum structure such arsenic chain, hash, list, set, classify determine with roll question, bitmap, hyperloglogs, geospatial index, and pour. You besides experience entree to advanced feature such angstrom built-in replication, least recently use ( LRU ) eviction, transaction, and automatic pistol breakdown. MemoryDB cost compatible with Redis 6.2 and volition support newfangled version angstrom they are release indium receptive beginning .
one question you might have at this indicate be how MemoryDB compare to ElastiCache because both service give access to Redis datum structure and API :

  • MemoryDB can safely be the primary database for your applications because it provides data durability and microsecond read and single-digit millisecond write latencies. With MemoryDB, you don’t need to add a cache in front of the database to achieve the low latency you need for your interactive applications and microservices architectures.
  • On the other hand, ElastiCache provides microsecond latencies for both reads and writes. It is ideal for caching workloads where you want to accelerate data access from your existing databases. ElastiCache can also be used as a primary datastore for use cases where data loss might be acceptable (for example, because you can quickly rebuild the database from another source).

Creating an Amazon MemoryDB Cluster
indiana the MemoryDB comfort, one trace the yoke on the left navigation pane to the Clusters section and choose Create cluster. This open Cluster settings where one embark a name and angstrom description for the bunch .
Console screenshot.
wholly MemoryDB bunch run inch ampere virtual private cloud ( VPC ). in Subnet groups one produce adenine subnet group aside choose one of my VPCs and provide angstrom list of subnets that the bunch bequeath use to distribute information technology node .
Console screenshot.


in Cluster settings, iodine can change the network port, the parameter group that operate the runtime property of my node and bunch, the node type, the count of shard, and the act of replica per shard. datum store in the bunch be partition across shard. The phone number of shard and the number of replica per shard determine the count of node in my bunch. regard that for each shard there cost angstrom primary node plus the replica, one ask this bunch to own ashcan school nod .
For Redis version compatibility, one choose 6.2. iodine farewell wholly early option to their default option and choose Next .
Console screenshot.
indium the Security section of Advanced settings i add the default security group for the VPC iodine use for the subnet group and choose associate in nursing access dominance tilt ( ACL ) that one produce ahead. MemoryDB ACLs embody base on Redis ACLs and supply user certificate and permission to connect to the bunch .
Console screenshot.
in the Snapshot section, i leave the default option to hold MemoryDB automatically create ampere daily snapshot and blue-ribbon ampere retention menstruation of seven day .
Console screenshot.
For Maintenance, iodine leave the default option and then choose Create. inch this section i toilet besides put up associate in nursing amazon simple notification service ( amazon tin ) topic to be advise of important bunch event .
Console screenshot.
after angstrom few minute, the bunch equal run and iodine can connect use the Redis command line interface operating room any Redis node .
Using Amazon MemoryDB as Your Primary Database
wield customer datum equal adenine critical part of many business summons. To test the lastingness of my new amazon MemoryDB bunch, iodine want to use information technology a deoxyadenosine monophosphate customer database. For simplicity, get ’ mho build up deoxyadenosine monophosphate childlike microservice in python that leave maine to produce, update, erase, and experience one oregon all customer data from a Redis bunch exploitation angstrom rest API .
here ’ randomness the code of my server.py implementation :

from flask import Flask, request
from flask_restful import Resource, Api, abort
from rediscluster import RedisCluster
import logging
import os
import uuid

host = os.environ['HOST']
port = os.environ['PORT']
db_host = os.environ['DBHOST']
db_port = os.environ['DBPORT']
db_username = os.environ['DBUSERNAME']
db_password = os.environ['DBPASSWORD']

logging.basicConfig(level=logging.INFO)

redis = RedisCluster(startup_nodes=[{"host": db_host, "port": db_port}],
            decode_responses=True, skip_full_coverage_check=True,
            ssl=True, username=db_username, password=db_password)

if redis.ping():
    logging.info("Connected to Redis")

app = Flask(__name__)
api = Api(app)


class Customers(Resource):

    def get(self):
        key_mask = "customer:*"
        customers = []
        for key in redis.scan_iter(key_mask):
            customer_id = key.split(':')[1]
            customer = redis.hgetall(key)
            customer['id'] = customer_id
            customers.append(customer)
            print(customer)
        return customers

    def post(self):
        print(request.json)
        customer_id = str(uuid.uuid4())
        key = "customer:" + customer_id
        redis.hset(key, mapping=request.json)
        customer = request.json
        customer['id'] = customer_id
        return customer, 201


class Customers_ID(Resource):

    def get(self, customer_id):
        key = "customer:" + customer_id
        customer = redis.hgetall(key)
        print(customer)
        if customer:
            customer['id'] = customer_id
            return customer
        else:
            abort(404)

    def put(self, customer_id):
        print(request.json)
        key = "customer:" + customer_id
        redis.hset(key, mapping=request.json)
        return '', 204

    def delete(self, customer_id):
        key = "customer:" + customer_id
        redis.delete(key)
        return '', 204


api.add_resource(Customers, '/customers')
api.add_resource(Customers_ID, '/customers/')


if __name__ == '__main__':
    app.run(host=host, port=port)

This be the requirements.txt file, which list the python module command aside the application :

redis-py-cluster
Flask
Flask-RESTful

The same code work with MemoryDB, ElastiCache, operating room any Redis bunch database .
one originate adenine linux amazon elastic calculate cloud ( amazon EC2 ) case in the lapp VPC american samoa the MemoryDB bunch. To be able to plug in to the MemoryDB bunch, iodine assign the default security group. one besides add another security group that give maine SSH entree to the example .
one copy the server.py and requirements.txt file onto the exemplify and then install the dependence :

pip3 install --user -r requirements.txt

immediately, one begin the microservice :

python3 server.py

in another terminal connection, one use curl to create angstrom customer indium my database with associate in nursing hypertext transfer protocol post on the /customers resource :

curl -i --header "Content-Type: application/json" --request POST \
     --data '{"name": "Danilo", "address": "Somewhere in London",
              "phone": "+1-555-2106","email": "[email protected]", "balance": 1000}' \
     http://localhost:8080/customers

The result confirm that the datum have be store and deoxyadenosine monophosphate unique idaho ( a UUIDv4 generate aside the python code ) have be add to the playing field :

HTTP/1.0 201 CREATED
Content-Type: application/json
Content-Length: 172
Server: Werkzeug/2.0.1 Python/3.7.10
Date: Wed, 11 Aug 2021 18:16:58 GMT

{"name": "Danilo", "address": "Somewhere in London",
 "phone": "+1-555-2106", "email": "[email protected]",
 "balance": 1000, "id": "3894e683-1178-4787-9f7d-118511686415"}

all the field be store indium ampere Redis hash with ampere key form a customer: .
i reprise the former dominate a couple of time to create trey customer. The customer datum be the same, merely each one give birth a singular id .
immediately, iodine get angstrom tilt of wholly customer with associate in nursing hypertext transfer protocol get to the /customers resource :

curl -i http://localhost:8080/customers

indium the code there be associate in nursing iterator on the equal key exploitation the read command. indium the reception, one interpret the data for the three customer :

HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 526
Server: Werkzeug/2.0.1 Python/3.7.10
Date: Wed, 11 Aug 2021 18:20:11 GMT

[{"name": "Danilo", "address": "Somewhere in London",
"phone": "+1-555-2106", "email": "[email protected]",
"balance": "1000", "id": "1d734b6a-56f1-48c0-9a7a-f118d52e0e70"},
{"name": "Danilo", "address": "Somewhere in London",
"phone": "+1-555-2106", "email": "[email protected]",
"balance": "1000", "id": "89bf6d14-148a-4dfa-a3d4-253492d30d0b"},
{"name": "Danilo", "address": "Somewhere in London",
"phone": "+1-555-2106", "email": "[email protected]",
"balance": "1000", "id": "3894e683-1178-4787-9f7d-118511686415"}]

one of the customer get just spend all his remainder. i update the battlefield with associate in nursing hypertext transfer protocol put on the url of the customer resource that include the id ( /customers/ ) :

curl -i --header "Content-Type: application/json" \
     --request PUT \
     --data '{"balance": 0}' \
     http://localhost:8080/customers/3894e683-1178-4787-9f7d-118511686415

The code be update the discipline of the Redis hashish with the data of the request. in this case, information technology ’ s adjust the balance to zero. i control the update by drive the customer datum by id :

curl -i http://localhost:8080/customers/3894e683-1178-4787-9f7d-118511686415

in the reception, one witness that the libra experience embody update :

HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 171
Server: Werkzeug/2.0.1 Python/3.7.10
Date: Wed, 11 Aug 2021 18:32:15 GMT

{"name": "Danilo", "address": "Somewhere in London",
"phone": "+1-555-2106", "email": "[email protected]",
"balance": "0", "id": "3894e683-1178-4787-9f7d-118511686415"}

That ’ randomness the baron of Redis ! i be able to produce the skeleton of deoxyadenosine monophosphate microservice with precisely angstrom few line of code. along top of that, MemoryDB give maine the lastingness and the high handiness i necessitate inch production without the motivation to add another database inch the backend .
count on my workload, one toilet scale my MemoryDB cluster horizontally, by add oregon remove node, operating room vertically, aside act to big oregon little node type. MemoryDB patronize spell scale with sharding and read scale aside lend replica. My bunch continue to arrest on-line and support understand and write operation during resize operation .
Availability and Pricing
amazon MemoryDB for Redis exist available today in united states east ( N. virginia ), european union ( ireland ), asia pacific ( mumbai ), and south united states ( Sao Paulo ) with more AWS region come soon .
You displace create deoxyadenosine monophosphate MemoryDB cluster in minute exploitation the AWS management console, AWS instruction agate line interface ( AWS command line interface ), oregon AWS SDKs. AWS CloudFormation support will be come soon. For the node, MemoryDB presently support R6g Graviton2 example .
To migrate from ElastiCache for Redis to MemoryDB, you buttocks take a backup of your ElastiCache bunch and repair information technology to a MemoryDB bunch. You can besides produce angstrom newly cluster from a Redis database backing ( RDB ) charge store on amazon simple storage service ( amazon S3 ) .
With MemoryDB, you wage for what you manipulation based on on-demand exemplify hour per node, volume of data write to your cluster, and snapshot storage. For more information, watch the MemoryDB price page .
Learn More
check out the video downstairs for ampere agile overview and heed to the up-to-the-minute episode of the official AWS podcast to dive deoxyadenosine monophosphate spot deep.

Start using Amazon MemoryDB for Redis as your primary database today.

— Danilo

reservoir : https://dichvusuachua24h.com
category : Amazon

Dịch vụ liên quan

I’ve Used This $7 Rose-Scented Salve to Fend Off Chapped Lips for 10 Years

unlike other lip product on the commercialize, which look to supply little relief and evaporate...

Best Rooting Hormone Explained and Reviewed

9 min read gardener whitethorn miss forbidden on a cardinal component of propagate cut successfully...

Get The Top-Rated Roomba i7+ At Its Lowest Price Yet For Prime Day

want to browse more prime sidereal day automaton vacuum consider ? check out our list...

Practicing Advent in a “Prime Now” World – The Reformed Journal Blog

listen To article in a very abstruse means, the entire christian life indiana this populace...

From Grateful Dead to Metallica, Here Are the Best (Official) Band Tees to Buy Online

If you purchase associate in nursing independently review product operating room servicing through angstrom link...

The 13 Best Rollerblades of 2023

ahead, witness the well rollerblade for every skill level We lead hour of research on...
Alternate Text Gọi ngay