14.2 Microservices and Container Security Flashcards
What are the components of a typical web app?
- **front-end** server, responsible for displaying webpages and styling them in a readable format. This server is also responsible for receiving and responding to HTTP requests.
- A **back-end** server, for executing business logic and writing or reading corresponding data to and from a database. The back-end server knows how to interact with the database depending on the specific request received.
- A **database**, used to store information about employees, such as their employee IDs and names.
Explain how information flows between application components: (8)
- Andrew loads the application in his browser and clicks a button to see all HR employees.
- Front end forwards the HTTP request to the back end.
- A back-end script queries the database for HR employees.
- Database searches for all IDs containing “HR.”
- Database sends IDs with “HR” to back end.
- Back-end script forwards list of HR employees to front end.
- Front end prepares a new webpage listing all of the HR employees.
- The browser displays a new page to Andrew, with a formatted list of HR employees.
Monolith to Microservices What is a monolith?
A monolith is any machine that hosts all of the components required to serve a website or application. In other words, a monolith is a machine that has the front-end server, the back-end server, and database all on one machine.
If Amazon used a monolithic server comprised of a front-end server, the back-end server, and database, it would contain: (3)
- A front-end HTML server: A GUI for customers to use when shopping. - A back-end MySQL server: A back-end server showing inventory and stock. - A MySQL database: A database of customers, their information, and purchases.
In the Amazon monolithic example, what would be the problems?
- If the company needs to update any of the components—the front end, back end, or database—the entire server and all of its components must be taken down. This creates long periods of downtime.
- If one component is compromised by a hacker, environmental issue, or human error, the entire machine is potentially compromised. Today’s business standards expect companies to ensure *availability* by maintaining almost 100% uptime. Because of this,
Amazon decides that the monolith architecture comes with too much risk, and instead creates a more ______ set up: a whole consisting of smaller and separate parts.
Amazon decides that the monolith architecture comes with too much risk, and instead creates a more **modular** set up: a whole consisting of smaller and separate parts.
The new approach of separating application components into their own machines is called __________.
The new approach of separating application components into their own machines is called **microservices**.
Each of the smaller blocks represent a single, independent machine. Within each machine is a component that executes one primary function or ________.
Each of the smaller blocks represent a single, independent machine. Within each machine is a component that executes one primary function or **service**.
The ultimate goal of microservices is _______ through _______, which has the following benefits:(4)
The ultimate goal of microservices is flexibility through modularity, which has the following benefits:
1. Scalability and resiliency: Replication of identical components allows you to serve more clients and provides identical backup components if one fails.
2. Rapid response: Since microservice components are inherently smaller than monoliths, they can be replaced and updated quickly.
For example, an entire VM might require 150 GB of total disk space. An individual component could have a maximum capacity of one or two hundred MB.
3. Isolated improvement: Since microservices should be reduced to serving one primary function, they can be developed to optimize their functionality.
- For example: Developers working on an API for storing employee data are developing a way to create new employee accounts more quickly. They’ll be able to work directly on this API, without the need of a front end to view it.
4. Isolated security: One compromised component does not equal a compromised application.
Since not every system uses Ansible to communicate, most systems use ________.
Most systems use **application programming interfaces (APIs)**.
Think of an API like a menu in a restaurant. The menu provides a list of dishes you can order, along with a description of each dish. When you specify what menu items you want, the restaurant’s kitchen does the work and provides you with some finished dishes. You don’t know exactly how the restaurant prepares that food, and you don’t really need to.
Similarly, an API lists a bunch of operations that developers can use, along with a description of what they do. The developer doesn’t necessarily need to know how, for example, an operating system builds and presents a “Save As” dialog box. They just need to know that it’s available for use in their app.
This isn’t a perfect metaphor, as developers may have to provide their own data to the API to get the results, so perhaps it’s more like a fancy restaurant where you can provide some of your own ingredients the kitchen will work with.
What is the technical definition of API?
An API is the implementation of new protocols or features onto an existing software application to alter the way that application is used or accessed.
Explain what APIs allow developers to do:
APIs allow developers to save time by taking advantage of a platform’s implementation to do the nitty-gritty work. This helps reduce the amount of code developers need to create, and also helps create more consistency across apps for the same platform. APIs can control access to hardware and software resources.
How would you separate a monolith into microservices: (4)
- Separate each component of the monolith by function, moving it into its own machine.
- Add communication between each microservice.
- Turn the back-end server into an API to interact with more than just the front end.
- Rename the rest of the component services to match their main functions.
A primary challenge of microservices is _________ and _________ as the application and number of components grow.
A primary challenge of microservices is the increase in complexity and required maintenance as the application and number of components grow.
What are the benefits of using microservices?(4)
- Easier to build and maintain apps
- Organized around business capabilities
- Improved productivity and speed
- Flexibility and scalability