1 - Introduction
Welcome to the Developing Java Applications on AWS book! It will teach you how to develop applications that will run in the Amazon Web Services environment. Also, the reader will understand how various cloud services work and their interactions through applications that will be built throughout the chapters.
The reader who has decided to follow this book might already know the relevance that cloud computing application development has in various areas of technology and business. Much more than a trend, this approach to building systems and software applications has become necessary for many business areas. Currently, few segments still use their own infrastructure to host their applications, perhaps still motivated by insecurity and lack of knowledge in cloud computing infrastructure.
To follow this book, the reader must have prior knowledge of application development using the Java language and object-oriented programming. Language-specific knowledge such as frameworks and development tools will be presented throughout the book.
Other languages that appear will be used minimally for building scripts or configuration files, necessary for building applications and configuring the services that will be created.
The applications taught in this book will use modern frameworks and tools, such as Spring Boot and Docker. In this way, the reader will learn to work with such technologies in conjunction with cloud computing services.
1.1 - Who is this book for?
This book is intended for software developers, with or without experience in cloud computing and web development, who want to dig deeper into the services offered by Amazon Web Services.
It can also serve as a source of knowledge for system administrators and operators to familiarize themselves with Amazon Web Services cloud resource creation and administration tools.
1.2 - What is AWS
AWS stands for Amazon Web Service, Amazon’s cloud computing platform. Here one can build multi-purpose applications hosted on a robust and scalable infrastructure using services such as databases, servers, data storage devices, and more.
A typical example of what one can do using AWS is to create a virtual machine to run an application and connect it to a database to persist information, as shown in the following figure:
The two features shown in the figure are AWS services and will be detailed below, but they represent an instance of a virtual machine (Amazon EC2) where the application runs and the database service (Aurora) to persist application information.
At this point, there is nothing new, but these features (the virtual machine and the database server) can be turned on or off as needed and can be modified in terms of processing and storage as the application demand grows or shrinks. Thus, the cost of using such resources can be adjusted according to the number of requests the application receives.
This feature of on-demand utilization of cloud computing resources is one of the significant advantages of this technology. Costs of using resources and services are somewhat accompanying variations in their usage, making their use attractive from a business standpoint and more financially viable.
Resources can be accessed directly from the Internet or protected with security rules based on various configuration parameters, such as being accessible only through other AWS resources, i.e., completely blocked from the “outside world”.
1.3 - AWS services and resources
This session will introduce some of the services and features offered by AWS, especially those covered in this book.
The intention is to briefly present some services with their nomenclatures and symbols, which will be used in the diagrams presented throughout the book, so the reader gets used to them when they appear.
All of the features presented here will be covered later in the book throughout its chapters. However, it is possible that, for didactic reasons, some resources are cited before they are formally presented, so a brief introduction to them is important.
a) Amazon Elastic Compute Cloud - EC2
Maybe this is the most popular service that AWS provides. With it, one can create virtual machine instances with different processing capacity, memory, and storage.
During the process of creating an EC2 instance, one can choose the operating system to run on the virtual machine. With this, after its creation, the virtual machine will be ready for use.
The symbol used to represent an EC2 instance in diagrams is the following:
With an EC2 instance, one can, for example, install a server and host a web application available across the Internet. One can also run an application inside a container using technologies like Docker, which will be used and explained throughout the chapters of this book.
b) Amazon Elastic Container Service - ECS
With ECS one can run applications inside containers such as Docker. Thus, one does not need to take care of administering instances of EC2 virtual machines that would host such applications.
Within an ECS, the system administrator can create tasks to run multiple virtual machines, causing the same application to have multiple instances running at the same time. This way, it’s possible to balance the processing and the requests between the various instances that are running the application. Also, it is possible to increase or decrease the number of instances automatically, according to such processing parameters and the number of requests.
The symbol representing an ECS is the following:
Running applications within containers have many advantages, especially concerning orchestrating the number of application instances to be executed and where traffic should be directed, in case of large requests or processing. This is a subject that will be addressed in this book as the concept of ECS is explored in more detail.
c) Amazon CloudWatch
CloudWatch is an Amazon Web Service monitoring and management service. Some of its most common functions are:
- Visualization of logs generated by other resources and applications;
- Metric graphs such as memory consumption and processing;
- Events visualization.
The symbol that represents CloudWatch is the following:
In a system with applications distributed across multiple instances or with different types of resources, it is crucial to have a way of concentrating this information in one place for easier monitoring.
d) Amazon Relational Database Service - RDS
This is a service for creating relational databases on AWS, such as Aurora, MySQL, PostgreSQL, Oracle, and SQL Server, without the need for server administration and operation.
The symbol representing RDS is the following:
RDS also offers benefits such as:
- Backup scheduling;
- Data recovering;
- Data replication;
- Monitoring and metrics.
e) Amazon DynamoDB
Amazon DynamoDB is a database based on documents and key-value structures. Quite unlike a relational database, in terms of data storage structure, this service has high-speed access operations at any scale.
The symbol representing the Amazon DynamoDB is the following:
Some of its features are:
- Backup scheduling;
- Data recovering;
- A mechanism that allows notifying the application in case of records changing;
- High performance for writing and reading operations;
- A mechanism for automatic records deletion.
f) Amazon Simple Queue Service - SQS
SQS is the AWS’s message queuing mechanism, for example, to establish communication between different applications.
The symbol that represents Amazon SQS is the following:
Following are some of the features of SQS:
- Guaranteed delivery of at least one message;
- Has mechanisms to prevent message order inversion.
g) Amazon Simple Notification Service - SNS
With AWS SNS one can send notification messages to mobile devices such as Android and iOS, as well to trigger events for other AWS features. It can also work seamlessly with AWS SQS to allow message propagation from one application to several at the same time.
The symbol representing the Amazon SNS is the following:
Here are some of its features:
- Allows integration with other AWS features such as SQS, Lambda, and S3;
- Several SQS can register in an SNS to receive notifications;
- Message protocol independency.
h) Amazon Simple Storage Service - S3
The AWS S3 is one of its mass object storage services. It is mainly used for temporary or non-temporary file storage with high access availability.
The symbol representing AWS S3 is the following:
Here are some of its features:
- High availability;
- It’s possible to send a notification to other AWS features when a new object is inserted;
- Has security settings to restrict public or private access.
i) AWS Lambda
Lambda is the AWS’s serverless code execution service.
With it, one can react to notifications or events and run a small chunk of code quickly, without having to maintain an idle virtual machine instance or server infrastructure.
The symbol that represents it is the following:
Some of the key features of AWS Lambda are:
- There is no need to create servers to execute source code;
- Multiple instances can be run to meet any request demand;
- The cost of using it is charged per code execution time, i.e., only when something needs to be executed.
1.4 - Didactic structure of the book
The didactic structure of this book permeates a concept known as problem-based learning, where the reader is introduced and led to key concepts through problems that must be solved using such knowledge.
Of course, not all concepts can be presented this way, but for those who allow, a more practical approach to learning will be used, so that the reader always has in mind a problem to be solved using the technology that is presented in detail. Thus, keeping in mind the target problem to be solved, the reader can absorb the concepts that are most efficiently presented.
1.5 - What will be needed
The next chapter details everything the reader will need to follow this book. Here is a summary so one can see that nothing unusual or costly will be used:
- Computer with Windows, OS X or Linux;
- Free development tools;
- AWS user account, which can be created in various ways for a free trial period;
- Code repository on GitHub.
The Postman tool will be widely used in this book to access REST services that will be created. The reader must be familiar with such a tool.
1.6 - AWS feature limitations by account type
There are certain resource restrictions that AWS imposes, depending on the type of account one use to access it. An example of this is the AWS Educate program, which offers credits for students and teachers, but which limits some resources or features.
These restrictions are under constant reviewing by AWS, so please check the ones that are imposed on your chosen account type.
1.7 - Next steps
In this chapter, the reader had a brief introduction to what AWS is, Amazon’s cloud computing service, and some of the features it offers. Also, it was presented as the book is structured.
In the next chapter, the reader will look at what to do to prepare his development environment and also the first steps that must be taken in the AWS administration console so that he can start building resources and developing applications.