当前位置:网站首页>Efficient NoSQL database service Amazon dynamodb experience sharing

Efficient NoSQL database service Amazon dynamodb experience sharing

2022-06-25 04:41:00 Songbird

One 、 Preface

Amazon has always been very active , So it gave me a chance to experience Amozon DynamoDB This fully managed distributed NoSQL Database services . in addition , Amazon cloud technology provides 100 Free packages for more than products . among , Computing resources Amazon EC2 First year 12 It's free for three months ,750 Hours / month ; Storage resources Amazon S3 First year 12 It's free for three months ,5GB Standard storage capacity ; Database resources Amazon RDS First year 12 It's free for three months ,750 Hours ;Amazon Dynamo DB 25GB storage capacity Free forever . Active address

Amozon DynamoDB What is it? ?

Amazon DynamoDB It's a fully managed NoSQL Database services , Equivalent to the NoSQL On the basis of a lot of expansion , Many functions of cost reduction and efficiency increase are added , So that developers don't need to maintain anything extra , Open the box . Its main services are : Seamless expansion , Fast and predictable performance , Reduce the tedious workload of managing distributed databases , Provide static encryption 、 Backup on demand 、 Automatically maintain expired items, etc . It can greatly reduce the time cost of developers and improve the construction efficiency .


Maybe some little friends are not clear NoSQL Difference from traditional relational database , Here is a brief introduction :

database Data sets structure advantage
Relational database form / Row and column storage The structure of a relational database is predefined , Tables can be related to each other 、 Constraints etc. . It can guarantee the security and integrity of data
NoSQL Key value pair ( Dictionaries ) structure In a non relational database , Data can be added at any time and anywhere . There's no need to predefine . High expansibility 、 A smaller 、 Faster .

therefore , If the business relationship is not copied 、 The dependency is simple and the fields need to be modified frequently , High performance requirements but low security requirements , Use DynamoDB It's a very good choice . On the contrary, it is recommended to use such as mysql This kind of traditional relational database .



Two 、Amozon DynamoDB Hands on Tutorial

1) Account registration

No, AWS Account partners need to register their accounts first : Registration and trial address ( Domestic credit cards can be used on the bill registration page )

2) Create and query NoSQL surface

2.1 Build table

After setting up an account , According to the official DynamoDB Use the tutorial You can quickly create NoSQL surface :

 Insert picture description here

2.2 Add data

There is a slight discrepancy with the official documents , You can actually do this by clicking on the name of the table in the list - Browse the project - Create a project to create , As shown in the figure below :

 Insert picture description here

2.3 Query data

Then click the run button ( You can also set filter criteria ) You can query the data we just added :

 Insert picture description here

2.4 Delete / Modifying data

Select any data in the list , It can be in the upper right corner “ operation ” Button to modify or delete data :

 Insert picture description here
If you need to delete the table , Select the corresponding table data in the outer table list , Click the delete button :

 Insert picture description here

3) Use Python management DynamoDB

We can also use Python To manage DynamoDB, Official documents There are detailed tutorials , No more details here .

4) Record on pit

stay 《 Use Amazon DynamoDB and Amazon SNS Build turn based games 》 tutorial , Follow the steps to application deployment , perform :bash scripts/create-lambda.sh The command displays the error message in the following figure :

 Insert picture description here


Follow the prompts to execute create-lambda.sh The file execution command is changed to nodejs14.x after , After deleting the newly created resource, the operation will be successful :

 Insert picture description here

There is also a green light behind , Completed the construction of turn based game .


3、 ... and 、Amozon DynamoDB Description of characteristics

1)DynamoDB The partitioning key 、 Understanding of sorting keys

1.1 The partitioning key

When we build tables , Will let us designate zones to build :


 Insert picture description here


What is the function of the partitioning key ? Here is an example to illustrate :

For example, there is such a ID number :210122199206140257, From this ID number, you can quickly know that this is a person from Liaoning Province 、 Shenyang .、 A member of Liaozhong County 29 Year old boy .
Description of ID card format rules : front 1-6 Bit is the administrative division code, i.e. the place of ownership , The first 7-14 Date of birth , The first 15-17 Bit is sequence code , People born in the same area are distinguished by serial numbers , The first 17 Odd number means male , Even numbers for women , The first 18 Bit is check code , Used to verify whether the ID card number is legal .
and DynamoDB The partitioning key of has the same function , Partition the data by specifying the identity , In this way, the query data will be significantly improved .

1.2 Sort key

The sort key allows us to store our data in a specified sort , In the subsequent data acquisition, the time complexity of the query can be reduced by means of binary search .

2)DynamoDB Secondary index of

In such as Mysql In relational databases such as , Indexing allows us to look up the data we want , Instead of scanning the entire table, query the data of the specified row range through the index , It's faster . After index creation , Let's modify the data of the table , The database automatically changes the index to map changes to the table , No need for us to operate it manually .

stay dynamodb How to implement similar operations in ?

We can create a secondary index to achieve a similar purpose ,DynamoDB Index and oracle,mysql The indexes of these relational databases are very different .DynamoDB The secondary index of is composed of a hash Keys and multiple range Key , It is essential to support the query patterns required by the application , About DynamoDB The use and introduction of the index can be accessed Manage index Document learning .

3)DynamoDB Backup and restore of

Data backup and rollback recovery are critical ,DynamoDB Fully automated on-demand backup 、 Restore and point in time recovery capabilities :


 Insert picture description here


in addition , At the same time of backup , It also encrypts the data automatically , Cataloguing , To improve the efficiency of management , We can perform backup settings in the backup tab of the table details page :
 Insert picture description here


You can also create one-time backups on demand :

 Insert picture description here


You can also visit Cloud native database online conference Understand the history of database development , And the future development direction .


Four 、 summary

DynamoDB In addition to providing data access management functions , In high availability ( Expand 、 Backup, etc ) We have also made a lot of efforts , There are also many out of the box services . therefore , It can not only ensure high-performance data access in the case of large-scale data , It can also reduce the construction, operation and maintenance costs of developers .
In game applications , news 、 It is necessary to send and receive notices , In addition, the performance requirements of game applications are much higher than those of traditional front and back-end applications , adopt Amazon DynamoDB and Amazon SNS The combination of , Can easily solve these two problems :


 Insert picture description here


Of course DynamoDB There are also scenarios that do not apply : In the early stages of product development , If there is no perfect and clear design scheme , Especially under the agile development mode of "step by step" , Not recommended DynamoDB, Because the DynamoDB Understanding of the document : Only when you are familiar with the product itself , To design its partition 、 Sort key and so on . In other words , When the product is in a mature stage , Or you are familiar with the product , Use DynamoDB It can definitely get twice the result with half the effort .

Amazon cloud technology has created a variety of learning platforms for developers :

  1. Getting started Resource Center : from 0 To 1 Easy to get started with cloud services , Content covered : Cost management , Start training , Development resources : Point me to visit
  2. Architecture Center : Amazon cloud Technology Architecture Center provides cloud platform reference architecture chart 、 Reviewed architectural solutions 、Well-Architected Best practices 、 Pattern 、 Icon, etc : Point me to visit
  3. Builder Library : Learn how Amazon cloud builds and operates software : Point me to visit
  4. Toolkit for developing and managing applications on Amazon cloud technology platform :: Point me to visit
原网站

版权声明
本文为[Songbird]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250333539876.html