Serverless Architecture: The Evolution of Cloud Computing

45acf4b48fbd29ddf47cef2486e290cf.gif

 The new titanium cloud service has shared 757 technical dry goods for you

b1530d1f8f874c7d9f765381e0147170.gif

With the development of serverless architecture on cloudscape, the following is based on MongoDB to talk about the views of serverless architecture and how they adapt to the changing era.

introduce

Building software has been a complex process since the dawn of computers. Over the past decade, new approaches to infrastructure (IaaS and PaaS), software architectures (SOA and microservices) and methodologies (agile, continuous delivery and DevOps) have emerged to ease the complexity of application development. While microservices have been a hot trend over the past few years, serverless architectures have gained momentum by offering a new approach to building scalable and cost-effective applications. Serverless computing frees developers from the traditional costs of building applications by automatically provisioning servers and storage, maintaining infrastructure, upgrading software, and charging only for resources consumed.

What is serverless computing?

Serverless computing is the lower abstraction state in cloud computing. That doesn't mean there are no servers, but the underlying infrastructure (physical and virtual hosts, virtual machines, containers), as well as the operating system, are all imagined from the developer's perspective. Applications are run in stateless compute containers triggered by events (for example, a photo uploaded by a user triggers a notification to his/her followers). Developers create applications and rely on the infrastructure to allocate the appropriate resources to execute the applications. If the load on the application grows, the infrastructure creates copies of the application and scales up to meet demand.

Serverless computing supports multiple languages, so developers can choose their favorite tools. Users are only charged for the runtime and the resources (such as RAM) consumed by the application; thus, there is no longer a concept of under-provision or over-provision.

For example, if an application runs for 500ms and consumes 15mb of RAM, then the user only needs to pay for the 500ms of running time and the cost of using 15mb of RAM.

Serverless architecture is a natural extension of microservices. Similar to microservices, serverless architecture applications are decomposed into specific core components. Microservices can group similar functionality into one service, while serverless applications divide functionality into finer-grained components. Custom code is developed and executed as independent, autonomous, fine-grained applications running in stateless computing services.

To illustrate this, let's look at a simple example of how microservices and serverless architectures differ.

In Figure 1, the client interacts with the "User" microservice. The container is pre-configured with all the functionality of the "User" service in the container. The service consists of different applications (update_user, get_user, create_user, delete_user) and scales according to the overall load of the entire service. Services will consume hardware resources when idle, and users will still be charged for underutilized resources.

a0c538bdeb814000813b06ebc0a0f88c.png

figure 1 

With a serverless architecture, the "user" service would be broken into finer-grained functions. In Figure 2, each API interface corresponds to a specific application and file. When a client makes a "create user" request, the entire codebase of the "user" service doesn't have to run; instead, only create_user.js executes. There is no need to pre-configure containers, because individual functions only consume resources when needed, and users only pay for the time their functions actually run. This granularity also facilitates parallel development efforts, as features can be tested and deployed independently.

e046c18c1477f104c342c27d73fc6d8a.png

figure 2 

Benefits of serverless computing

Cost increases with usage:

One of the greatest benefits of serverless computing is that you only pay for the time your application runs. There is no concept of "idle" resources, because you are not charged if the function is not being executed. This is especially useful for applications that are only used a few times per hour, meaning that any dedicated hardware, VMs, or containers sit idle most of the time, and users are charged for underutilized resources. With serverless computing, businesses can build out an entire infrastructure and not pay for any computing resources until customers start using the application.

Elastic scalability:

Elastic scalability with serverless architecture is also simple. If the application needs to scale, the infrastructure will make copies of the application to handle the load. An example of this might be a chatbot that responds to weather requests. In a serverless architecture, the chatbot function would handle the response by retrieving the user's location and responding with the temperature. For a small number of requests, this is not a problem, but what happens if the chatbot service is flooded with thousands of requests per second. For this case, the chatbot function will automatically scale by instantiating thousands of copies of the function. Once requests subside, the environment terminates idle instances and scales back in, allowing costs to scale proportionally to user demand.

Rapid development and iteration:

Serverless computing is ideal for companies that need rapid development, prototyping, and iteration. Development is faster because there is no dependency on IT operations. The application is single-threaded, which makes debugging and deploying the application easier. The build process is also broken down into smaller, more manageable chunks. This increases the number of changes that can be pushed through a continuous delivery pipeline, enabling rapid deployment and more iterative feedback. Iterate quickly because the architecture facilitates making large code changes quickly, resulting in more customer feedback and better product-market fit.

Less sysadmin:

Serverless doesn't mean you completely eliminate the operational element of your infrastructure, but it does mean less system administration. There is no need to manage, configure and scale servers, or to patch and upgrade. Servers are automatically deployed in multiple availability zones to provide high availability. Support is also simplified; if something goes wrong in the middle of the night, it's the cloud provider's responsibility to fix it.

Developer Productivity:

By using a serverless architecture, developers can focus more on writing code and not worry about the operational tasks of managing the application. This allows them to develop innovative features and focus on the core business logic that is most important to the business.

MongoDB Atlas and serverless computing

With MongoDB Atlas, users can leverage the rich capabilities of MongoDB—expressive query language, flexible architecture, always-on availability, distributed scale-out—from a serverless environment.

MongoDB Atlas is a database-as-a-service that provides all the functionality of a database without the heavy lifting of setting up operational tasks. Developers no longer need to worry about provisioning, configuration, patching, upgrades, backups, and failure recovery. Atlas provides elastic scalability, whether by scaling across a range of instance sizes or through automatic sharding, without downtime for all applications.

Setting up Atlas is easy.

a9735698b3f4c8053b3b7f3a438d1868.png

image 3 

Choose an instance size that fits your application needs, and click CONFIRM & DEPLOY. Depending on instance size, a MongoDB cluster can be provisioned in seconds.

dbf532aa0e6e12514ed8d60a3b0298bc.png

Figure 4 

MongoDB Atlas offers many benefits to those interested in building serverless architectures:

Supplier Independence:

Cloud vendors often only offer databases specific to that vendor, which may not fit a developer's needs. MongoDB Atlas provides independence from the underlying cloud provider and enables developers to choose the right tool for their needs. Developers can take advantage of the rich functionality of the MongoDB query language and flexible data model without worrying about the operational tasks of managing the database. If you decide to move to another cloud provider, you won't have to repopulate your data with a different database technology. MongoDB Atlas is currently only available on AWS, with support for Microsoft Azure and Google Cloud Platform (GCP) coming soon.

MEAN stack: 

Serverless architecture accelerates the trend of moving business logic from the backend to the frontend. This makes the choice of front-end framework more important. AngularJS is perfect for this requirement and is a popular front end for serverless architecture. AngularJS is a structured Javascript framework for dynamic web applications that provides interactive features and AJAX (a technology used to create fast and dynamic web pages) rich components. Combined with NodeJS, ExpressJS and MongoDB, these tools form the MEAN stack (MongoDB, ExpressJS, AngularJS, NodeJS). There are huge advantages to using JavaScript and JSON throughout the serverless stack. People who work on the front end can easily understand the application (back end) code and database queries. Additionally, using the same syntax and objects across the stack frees your team from understanding best practices in multiple languages ​​and lowers the barrier to entry for understanding your code base, improving software performance and developer productivity.

Quick deployment:

With MongoDB Atlas, a MongoDB cluster can be provisioned and deployed in minutes or even seconds. Developers no longer need to worry about configuring or managing servers. Integrating MongoDB Atlas into a serverless platform requires you to pass a connection string into your serverless application.

df2fe5c15d54552d6c6901bbdd9236fa.png

Figure 5 

MongoDB Atlas has extensive capabilities to defend, detect and control access to MongoDB, providing the most complete security controls of any modern database:

· User rights management: Use industry standard mechanisms to authenticate and authorize at the database level, controlling access to sensitive data

Encryption: Protect data in motion on the network and at rest in persistent storage

To ensure a secure system out of the box, authentication and IP address whitelisting are automatically enabled.

IP address whitelisting is a key security feature of MongoDB Atlas that adds an extra layer to prevent 3rd parties from accessing your data. Clients will not be able to access the database unless the client's IP address has been added to the IP whitelist of the MongoDB Atlas group.

 For AWS, VPC Peering for MongoDB Atlas is in development and will be available soon, providing a simple, powerful solution. It will allow whitelisting of the entire AWS security group within the VPC containing your application server.

Scalability:

You should expect your serverless functions to scale out, so your downstream setup needs to be architected to keep up with your functions and scale. Relational databases tend to break down with this model. MongoDB Atlas is designed with scalability as a core principle. MongoDB Atlas alerts you when your cluster reaches a certain threshold, and you can provision new servers with one click.

Flexible architecture:

Because serverless architectures are event-driven, many use cases revolve around the Internet of Things (IoT) and mobile devices. MongoDB is ideal for these use cases and more because its flexible document model enables you to store and process any type of data: event, geospatial, time series, text, binary, and anything else. Adding new fields to the document structure is simple and easily handles changing data generated by event-driven applications. Developers spend less time modifying schemas and more time innovating.

Original link:

https://dzone.com/articles/serverless-architectures-the-evolution-of-cloud-c

    recommended reading   

a39388b0178b70bbf437bb4ecdfd2cab.png

7634e2b969bc74a2d6dc2d0754859955.png

    recommended video    

Guess you like

Origin blog.csdn.net/NewTyun/article/details/131566519