Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building Serverless Microservices with Python

2,404 views

Published on

As we move to the different models of production, distribution, and management when it comes to applications, it only makes sense that abstracting out the, behind the scenes processes should be handled by third parties, in a move towards further decentralization. And that’s exactly what serverless computing does – and startups and big companies are adopting this new way of running applications.

In this post, we will discover answers to questions: What Serverless is all about and how does this new trend affect the way people write and deploy applications?

Read More: https://www.xenonstack.com/blog

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Building Serverless Microservices with Python

  1. 1. Building Serverless Microservices With Python NexaStack - DevOps Platform
  2. 2. Serverless Computing is Exploding ● As we move to the different models of production, distribution, and management when it comes to applications, it only makes sense that abstracting out the, behind the scenes processes should be handled by third parties, in a move towards further decentralization.
  3. 3. Serverless Computing is Exploding ● That’s exactly what serverless computing does – and startups and big companies are adopting this new way of running applications. ● In this post, we will discover answers to questions: What Serverless is all about and how does this new trend affect the way people write and deploy applications?
  4. 4. Serverless Computing ● “Serverless” denotes a special kind of software architecture in which application logic is executed in an environment without visible processes, operating systems, servers or virtual machines. ● It’s worth mentioning that such an environment is actually running on the top of an operating system and use physical servers or virtual machines, code.
  5. 5. Serverless Computing ● But the responsibility for provisioning and managing the infrastructure entirely belongs to the service provider. Therefore, a software developer focus more on writing code.
  6. 6. Serverless Computing Advances the way Applications are Developed ● Serverless applications will change the way we develop applications. ● Traditionally a lot of business rules, boundary conditions, complex integrations are built into applications .
  7. 7. Serverless Computing Advances the way Applications are Developed ● This prolongs the completion of the system as well as introduces a lot of defects and in effect, we are hard wiring the system for certain set of functional requirements. ● Below figure shows how the way of application development changed with time.
  8. 8. Serverless Computing Advances the way Applications are Developed ● Monolith- A monolith application puts all its functionality into a single process and scale by replicating the monolith on multiple servers. ● Microservice- A microservice architecture puts each functionality into a separate service and scale by distributing these services across servers, replicating as needed.
  9. 9. Serverless Computing Advances the way Applications are Developed ● FaaS- Distributing Microservices further into functions which are triggered based on Events. Monolith => Microservice => FaaS
  10. 10. Serverless Computing Advances the way Applications are Developed
  11. 11. Let’s get started with the deployment of a Serverless Application on NexaStack. To create a function, you first package your code and dependencies in a deployment package. Then, you upload the deployment package on our environment to create your function. Creating a Deployment Package Uploading a Deployment Package Serverless Computing Advances the way Applications are Developed
  12. 12. Database Integration for your Application ● Install MongoDB and configure it to get started. ● Create Database EmployeeDB ● Create table Employee ● Insert some records into the table for the demo.
  13. 13. Database Integration for your Application
  14. 14. Creating a Deployment Package – Organizing Code and Dependencies To create a function you first create a function deployment package, a .zip file consisting of your code and any dependencies. ● Create a directory, for example, project-dir.
  15. 15. Creating a Deployment Package – Organizing Code and Dependencies ● Save all of your Python source files (the .py files) at the root level of this directory. The folder named “app” serves this purpose in the demo. ● List any of the extra libraries used in a file “requirements.txt” ● Zip the content of the project-dir directory, which is
  16. 16. Creating a Deployment Package – Organizing Code and Dependencies
  17. 17. Creating Function ● Fill the entries as shown in below pic to upload a function. ● The port number field must be filled with a port number on which you want your service to run.
  18. 18. Creating Function
  19. 19. Testing● Once we are finished with uploading the function, Service is active to test. ● Click on "Test" and your service is up in few seconds on the port number specified in the previous step.
  20. 20. Serverless Architecture: Still in Development! ● There are some problems with the maturity of the FaaS technologies at this point. ● There is no organizational framework for FaaS. ● This means that your company may write hundreds or even thousands of these functions and after a while, nobody may know what functions are still used or if the code is replicated.
  21. 21. Continued…... ● Serverless is not efficient for long-running applications. In certain cases, using long tasks can be much more expensive than, for example, running a workload on a dedicated server or virtual machine. ● Vendor lock-in: Since the application completely depends on a third-party provider so we don’t have a full control of your application. Also, we are dependent on platform availability, and the platform’s API and costs can change.
  22. 22. Continued…... ● Serverless (and microservice) architectures introduce additional overhead for function/microservice calls. There are no “local” operations; you cannot assume that two communicating functions are located on the same server. ● Cold Start: A platform needs to initialize internal resources ( needs to start a container). The platform may also release such resources (such as stopping the container) if there have been no requests to your function for a long time.
  23. 23. Continued…...One option to avoid the cold start is to make sure your function remains in an active state by sending periodic requests to your function. ● Some FaaS implementations—such as AWS Lambda—do not provide out-of-the-box tools to test functions locally (assuming that a developer will use the same cloud for testing). This is not an ideal decision, especially considering that you will pay for each function invocation. As a result, several third-party solutions are trying to fill this gap, enabling you to test functions locally.
  24. 24. Summary Serverless Framework is growing both in size itself and in the community, so jump on board and discuss business opportunities with us.
  25. 25. Free Trial For Customized Product Demo, Visit: https://www.nexastack.com
  26. 26. For Product & Customized Demo Reach Us At: https://www.nexastack.com Email: business@xenonstack.com www.xenonstack.com Connect With Us On Social Media

×