Document Databases
A document database is a non-relational (or NoSQL) database that allows you to store documents and data in the JSON-type format and query that data. One of the truly unique features of document databases is that there is no fixed schema and that they can have documents nested inside of each other.
AWS provides Amazon DocumentDB (with MongoDB compatibility) as a managed database service for users who have either used MongoDB in the past or are looking for the capabilities of a document database.
Document databases are particularly good for teams that don’t want to deal with the administrative aspects of a database, want to simplify the way to use initial schema values with JSON, and want to start pushing data to the database, which will allow both simple and advanced querying later.
As you start to build out cloud-scale applications, you need ways to decouple different tiers of the application so that it can scale independently. This is for several reasons, including making your application more resilient and allowing each available tier to scale independently of the other tiers. You might only need to have a single EC2 instance running at any point in time. Encapsulating this instance in an autoscaling group and connecting it to a managed queue allows the queue to take the requests and ensure that they get processed by the EC2 instance, even if it happens to stop and terminate for some reason. In another scenario, if there is a burst of traffic for any amount of time and it is too much for the single instance to handle, then having the request flow first in a queue allows an auto-scaling group to scale up more instances based on the number of requests coming in at a certain point in time. This is easy to think of in an order processing system, where, with a normal load of traffic, a single EC2 instance can handle the job. However, when there is a lot of traffic, for instance, if there has been a promotion by the marketing department and a flood of new orders have come through the system, then the number of orders, if they were going through the queue, would signal that more than one instance would be needed to complete the job in a timely manner.
The following sections will take you through the message and queueing systems provided by AWS, how they can benefit you, and some of their security considerations.
Simple Notification Service (SNS)
The ability to allow either your applications or even other AWS services to send messages and notifications without extra programming or complex configuration is provided by Simple Notification Service (SNS).
SNS is a publisher and consumer system where publishers are able to push a message out to a topic, and then any consumer who has subscribed to that topic can consume that message.
The SNS topic acts as the channel where a single message can be broadcast to one or more subscribers. The publisher (in this case, the application shown in Figure 2.6) only sends the message out once to the topic, and each consumer (or subscriber) can receive the message to be processed in the way that works for them.
Figure 2.6: Architecture showing SNS fanout