Model-Oriented Software Architecture 3-resource management model Reading Notes (8)-resource lifecycle manager Model

Source: Internet
Author: User

3.4 Resource lifecycle manager Mode

The resource lifecycle manager mode introduces a separate resource lifecycle manager, which decouples the resource lifecycle management with their usage.

 

1. Problem

Building a large-scale system is very challenging. It makes large-scale systems robust and scalable. How to manage resources is the most important factor that makes large-scale systems robust and scalable. Resources in the system may have many different types, such as network connections, threads, synchronization primitives, and services. Network Connection represents the customer's ApplicationProgramAnd distributed application services. Efficient management of them requires the ability to determine when to establish a connection and when to release the connection. Threads are especially important to large-scale systems because they provide asynchronous behavior between different parts of the application. For example, they can provide decoupling between UI interaction and typical client functions and services. However, efficient thread management is challenging because it involves closely monitoring their execution and determining when to create a thread and when to release unnecessary threads. Similarly, we usually need synchronization primitives such as locks and tokens to synchronize the asynchronous parts of the application and make their internal coordination and interaction possible. However, it is important to know when and how to create these synchronization primitives, And the implementation is also accurate.

1) availability ). The number of available resources usually does not increase along with the overall size of the system. Therefore, it is important to manage resources effectively and efficiently in a large system so as to ensure that resources are available when necessary.

2) scalability ). As the system grows, the number of resources to be managed increases, making it more difficult for users to directly manage.

3) complexity ). Large systems usually have complex interdependent relationships between resources and it is difficult to trace these relationships. To ensure that resources can be correctly and timely released when they are no longer needed, it is important to maintain and track these dependencies.

4) performance ). Generally, many optimizations aim to ensure that the system does not encounter any performance bottlenecks. However, such optimization by a single resource user may be quite complicated.

5) stability ). If resource users have to manage resource lifecycle items, they may forget to release resources. Over time, system stability problems may occur. In addition, it is necessary to control the acquisition of resources to ensure that resources available at the system level do not suffer from "famine", thus avoiding instability.

6) interdependencies ). In a complex system, the same or different types of resources may depend on each other, which means that the resource lifecycle is also dependent on each other and needs to be managed correctly.

7) flexibility ). Resource lifecycle management should be flexible and support different policies. The policy should provide hooks to allow resource management configuration.

8) Transparency ). Resource lifecycle management should be transparent to resource users. In particular, resource users should not be forced to deal with the complexity of resource management.

 

2. Solution

Separates resource usage from resource management. Introduce a separate resource lifecycle Manager (rlm). Its only responsibility is to manage and maintain resources used by resource users.

Resource users can use rlm to obtain and access specific resources. If the requested resource does not exist, rlm creates the resource. In addition, rlm allows users to explicitly create resources.

Rlm knows the current resource usage, so it can reject resource access requests from resource users. For example, when the system has very few available memory, rlm can reject resource users' memory allocation requests.

Rlm also controls the collection of resources it manages, or is transparent to users, or responds to users' explicit requests. Rlm maintains resources based on appropriate policies that take into account available computing resources (such as memory, connections, and file handles.

Rlm can be responsible for one type of resources or multiple types of resources. If there is a dependency between resources, rlm for each type of resources will work collaboratively, which means they need to maintain the dependency between resources. This can be the responsibility of a central rlm for the other rlm and their dependent resources, or a separate rlm can only process the dependency between each other, and leave the management of the same type of resources to the rlm of various types of resources. In a layered architecture, you can use hierarchical rlm. Such rlm exists at each abstract level (such as the OS, framework, and application layer.

 

3. Structure

Resource users obtain and use resources.

A resource is an entity (such as a network connection or thread ).

The resource lifecycle Manager (rlm) manages the lifecycle of resources, including their creation, retrieval, reuse, and structure.

Resource providers (such as operating systems) possess and manage resources. The resource provider can also be a resource lifecycle manager at the same or different abstract levels.

 

 

4. Implementation

1) determine the resource to be managed. Developers must first identify all resources that need to manage the lifecycle. Because the types of resources are diverse, applications can provide multiple rlm for different types of resources. For example, an rlm is used to process computing resources such as processes, threads, file handles, and connections, another rlm is used to maintain application components. However, you can also use an rlm to process different types of resources. When you need to maintain complex dependencies between different types of resources, such a solution may be more effective. If you only need one rlm instance, it should be implemented as Singleton.

2) define the meaning of Resource Creation and retrieval. Developers need to determine how rlm creates or obtains resources.

This includes deciding when to create or obtain resources, as well as how to create or obtain resources. Eager acquisition, lazy acquistion, partial acquisition and other modes can be used to control when to obtain resources, while the factory method mode and abstract factory mode can control how to create resources. Note that resources are usually obtained by rlm, so rlm can have full control over the lifecycle of these resources. However, there may also be situations where resources are not obtained or created by rlm, but need to be managed by rlm.

To ensure system stability, rlm can deny resource access requests from resource users for multiple reasons (including insufficient resources.

3) define the meaning of resource management. Rlm manages resources effectively and efficiently. Frequent Resource Acquisition and release may be costly. Therefore, rlm usually uses the caching and pooling modes to optimize resource management.

4) process resource dependencies. To manage resource dependencies, you can consider using an rlm with common responsibilities. The exact feasibility of such rlm and its implementation are closely related to the application background and resource type. One possible solution is to divide mutually dependent resources into a group. Such groups can be used to control the acquisition, access, and release of mutually dependent resources.

5) define the meaning of resource release. When resources are no longer needed, they should be automatically released by rlm. Leasing and Evictor modes can be used to control when and how to release resources.

6) define the resource access semantics. The created or retrieved resources should be easy to access. Rlm can use lookup and other modes to easily access resources.

7) configure the policy. For each step above, rlm should allow you to configure different policies to control how to manage the resource lifecycle.

 

5. Conclusion

Advantages:

1) efficiency ). The efficiency of a single user to manage resources is relatively low. The resource lifecycle manager mode allows resource coordination and centralized lifecycle management, which makes further application optimization possible and reduces the overall complexity.

2) scalability ). The resource liftcycle manager mode allows more effective resource management, allowing applications to make better use of available resources, which allows applications to withstand higher loads.

3) performance ). The resource lifecycle manager mode ensures that optimization at multiple layers is possible to achieve optimal performance from the system. By analyzing resource usage and availability, different policies can be used to optimize system performance.

4) Transparency ). The resource lifecycle manager mode makes Resource Management transparent to users. Different policies can be configured to control Resource Creation, acquisition, management, and release. By coupling resource usage and resource management, rlm reduces the complexity of use and makes resource users easy.

5) stability ). The resource lifecycle manager mode ensures that resources are allocated to users only when there are sufficient resources, this avoids the resource "famine" that is easily caused when resource users can directly obtain resources from the system, which helps improve the system stability.

6) control ). The resource lifecycle manager mode allows you to better control the management of mutually dependent resources. By maintaining and tracking dependencies between resources, rlm can release resources correctly and timely when they are no longer needed.

 

Disadvantages:

1) single point of failure (single point of failure ). A bug or error in rlm may cause many parts of the application to fail. The concept of redundancy can only play a part, because the complexity is further increased and the performance is further restricted.

2) flexibility ). When a single resource instance needs special treatment, the resource lifecycle manager mode may not be flexible enough.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.