Application design considerations

There is more to designing an autoscaling strategy than only adding resources to a system or running more instances of the system. You should consider the following point when designing an autoscaling strategy from an application perspective:

  • If your application or system implements a long-running task, the task needs to be designed for both scaling in and scaling out. Without this, the task can lose data if it is forcibly terminated, or the task can prevent an instance of a process from being shut down. The best approach is to break up the task into smaller pieces, so that it can be picked up by other instances easily.
  • The application or system must be designed to scale horizontally. Do not design solutions that require that the code is always running in a specific instance of a process. For web apps, don't assume that all web requests are made to the same instance. Design stateless services whenever possible. You can implement a checkpoint mechanism that records state information at regular intervals. This state can then be saved into durable storage, which can then be accessed from all the instances.
  • The length of a queue that is used for communication from the UI with the backend of the application is a good criterion for your autoscaling strategy. This is the best indicator of an imbalance between the current load and the load capacity. 
  • Autoscaling is not always the best mechanism for handling more requests on the system. It takes some time before it is provisioned and before new instances are started. And the peak moment may have passed by before all the resources are added. In this case, throttling is a better approach.
  • Consider limiting the maximum number of instances that can automatically be added in order to prevent that excessive scale. Most autoscaling mechanisms allow you to specify the minimum and a maximum number of instances for a rule. 
  • Monitor the autoscaling process, and log the details of each autoscaling event (what triggered it, what resources were added or removed, and when this happened).

The following patterns may be relevant for the scenario where you want to implement autoscaling:

  • Pipes and filters pattern: This pattern describes how you can decompose a task that performs complex processing into a series of separate elements that can be reused. This allows task elements to be deployed and scaled independently.
  • Competing consumers pattern: This pattern describes how a pool of service instances can be implemented that can handle messages from any application instance. 
  • Throttling pattern: Throttling can be used together with autoscaling to prevent an application or system from being overburdened. This pattern describes how an application can continue to execute and meet SLAs when an increase in demand places an extreme load on the resources. 
If you want more information about cloud patterns, you can refer to the following website: https://docs.microsoft.com/en-us/azure/architecture/patterns/. The URLs to the preceding patterns can be found in the Further reading section at the end of this chapter.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.185.42