Method for sharing service between Android containers

By extracting shareable services from Android containers and running them as public services in the host, and combining with the new binder driver to achieve cross-container communication, the problems of Android container resource expansion and communication limitations are solved, and resource utilization and system stability are optimized. .

CN118550733APending Publication Date: 2024-08-27SHENZHEN VIRTUAL CLUSTERS INFORMATION TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410734542.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Existing Android containers have problems such as resource expansion and waste, inability to communicate across containers, and unclear division of responsibilities in service processes, resulting in increased hardware resource usage and increased system management burden.

Method used

Extract sharable services from inside the container and run them on the host as public services, and introduce a new binder driver that supports cross-container communication. The public service manager manages and coordinates communication between containers, reducing the number of processes and clarifying services. Responsibilities.

Benefits of technology

It effectively reduces resource expansion and waste, optimizes system resource utilization, realizes efficient communication and resource sharing between containers, improves system collaboration capabilities and stability, clarifies the division of service responsibilities, and improves system maintenance and upgrade efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550733A
    Figure CN118550733A
Patent Text Reader

Abstract

The invention discloses a method for sharing services based on Android containers, which comprises the following steps of: creating a plurality of Android container instances in a host machine through a container technology, and running a complete Android system in each container; distributing a private binder drive instance in each container through binder fs, wherein the process in the container communicates through the drive instance; part of sharable services are extracted from the interior of the container and run in the host machine as public services; communication between the container and a host machine public service is realized through a binder driver of cross-container communication; and a public service manager is arranged in the host machine, manages public services and registers the public services to the namespace of the host machine. According to the invention, the public service manager is arranged in the host machine, and part of sharable services are extracted from the interior of the container to the host machine for operation, so that cross-container communication between the container and the host machine is realized, repeated occupation of resources is reduced, the resource utilization efficiency of the system is improved, the performance is optimized, and the system is suitable for popularization and application. And through the load balancing and log monitoring module, the stability and maintainability of the system are further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer software, and in particular to a method for sharing services between Android containers. Background Art

[0002] AIC Android container technology (Android in Container) is the mainstream technology solution for cloud computing applications and cloud phones and cloud games. In this solution, multiple containers are created in the host machine through container technology and the complete Android system is run in the container, thereby realizing a method of virtualizing multiple Android devices on one hardware device.

[0003] In the Android operating system, different processes need to communicate and collaborate to meet the different functional requirements of users: for example, when a user makes a call, the dial-up interface process needs to communicate with the system communication module to complete the common needs of making a call.

[0004] Traditional process communication solutions cannot meet the performance requirements of embedded devices. Google has specially designed a binder driver module that runs in the operating system kernel. The process completes the communication between two processes through this driver through system calls.

[0005] In the AIC scenario, each container is allocated a private binder driver instance through binderfs, and the processes in the container communicate through this driver instance.

[0006] Problems with existing Android containers:

[0007] Resource bloat and waste

[0008] When the hardware runs multiple container instances, each container contains a complete Android system. Since the Android system is not designed for cloud hosts, the service processes in each container implement the same functions. As the number of container instances increases, the number of actual processes running in the hardware increases exponentially, and the hardware resources occupied by the system (mainly RAM, FLASH, CPU) increases exponentially. The increase in the number of processes will burden the operating system's process management and job scheduling (mainly CPU).

[0009] Containers cannot communicate across containers via binder

[0010] Containers can only communicate within the container through binder, which is an efficient process communication solution, but cannot communicate across containers.

[0011] Unclear division of responsibilities between service processes in the container

[0012] When native Android runs in a container, it becomes unclear which services should actually interact with real hardware and which should be implemented virtually.

[0013] For example, a native service process needs to operate the GPIO port of the hardware and set its level to high. After containerization, each container will have such a service and will repeatedly operate this GPIO.

[0014] like Figure 1 As shown, from Figure 1 We can see that after the native Android application is applied to the AIC scenario, each Android container communicates through the binder driver, and the binder driver devices inside the container are not visible to the outside.

[0015] like Figure 2 As shown, in the current AIC solution, services mostly exist in the form of separate processes, and multiple containers have N separate copies of services. Summary of the invention

[0016] In order to solve the above problems, the present invention provides a method for sharing services between Android containers, which solves the problems of resource expansion and waste, the inability of containers to communicate across containers through binder, and the unclear division of responsibilities of service processes in containers. By extracting services that can be shared from the inside of the container as public services, the number of processes is effectively reduced, and the problems of repeated waste and rapid expansion of resources caused by the increase of container instances are reduced. A new type of binder driver that supports cross-container communication is introduced, and the container can request services from external shared services to achieve cross-container communication. After moving the shareable services to the outside of the container, repeated operations on the hardware are avoided. The container retains its own virtualized services as needed, and the division of responsibilities is clearer and more specific.

[0017] The present invention is implemented by the following technical solution: A method for sharing services between Android containers, comprising the following steps:

[0018] Step 1: Create multiple Android container instances in the host machine using container technology, and run a complete Android system in each container;

[0019] Step 2: Allocate a private binder driver instance inside each container through binderfs, and the processes in the container communicate through this driver instance;

[0020] Step 3: Extract some sharable services from the container and run them in the host as public services.

[0021] Step 4: Use the binder driver for cross-container communication to realize communication between the container and the host public service;

[0022] Step 5: Set up a public service manager in the host to manage public services and register them in the host namespace.

[0023] As a preferred technical solution, the public service includes public service 1 and public service 2. The public service is transmitted through / dev / public_binder, / dev / public_hwbinder and

[0024] / dev / public_vndbinder communicates with the container.

[0025] As a preferred technical solution, the public service manager in the host manages and coordinates cross-container communication between containers by registering public services, including registration and deregistration operations of services.

[0026] As a preferred technical solution, the service in the container communicates with the public service in the host machine through a proxy program. The proxy program replaces the original service process inside the container and accesses the public service through a binder driver for cross-container communication.

[0027] As a preferred technical solution, the public service manager is configured with a service discovery module for dynamically discovering and managing public services in the host machine.

[0028] As a preferred technical solution, the zygote process in the container is moved from the inside of the container to the outside of the host machine, and a lightweight zygote agent is implemented inside the container. The zygote agent is used to maintain the communication between the zygote and the system service, including forwarding the request to create a process.

[0029] As a preferred technical solution, after the external zygote incubates the new process, the new process is transferred to the namespace inside the container through the namespace isolation technology.

[0030] As a preferred technical solution, the public service manager further includes a load balancing module for distributing public service requests among multiple container instances to optimize resource utilization and performance.

[0031] As a preferred technical solution, a log monitoring module is provided in the host machine for monitoring the running status of cross-container communication and public services to facilitate fault diagnosis and performance optimization.

[0032] As a preferred technical solution, some service processes in the container are retained as needed and dynamically adjusted through configuration management tools to adapt to different workload requirements and improve system maintenance efficiency.

[0033] The beneficial effects of the present invention are as follows: the present invention effectively reduces resource expansion and waste and optimizes the resource utilization efficiency of the system by extracting the shareable services from the container and running them as public services in the host machine. Through this solution, each container no longer needs to run a complete set of services, but is uniformly managed and coordinated through a public service manager, which significantly reduces the number of processes and resource usage, especially in terms of memory and CPU usage.

[0034] The introduction of a new binder driver that supports cross-container communication enables efficient communication between containers and between containers and the host. Traditional Android containers can only communicate within the container, which limits the collaboration and resource sharing between containers. Through the new binder driver, containers can seamlessly request and use public services in the host, greatly improving the system's collaboration capabilities and resource utilization.

[0035] By moving some services to the host machine, duplication of hardware operations is avoided, the division of responsibilities of service processes is clarified, and virtualized service processes are retained on demand within the container without the need to repeat hardware operations. This not only reduces resource consumption, but also avoids possible operational conflicts, improves system stability and maintainability, and makes the division of responsibilities of services clearer, which is conducive to system maintenance and upgrades.

[0036] In addition, the present invention sets up a load balancing and log monitoring module in the host machine to further optimize resource allocation and system performance. The load balancing module can dynamically allocate service requests to ensure efficient utilization of system resources and performance optimization. The log monitoring module provides real-time monitoring of the system operation status, facilitates fault diagnosis and performance optimization, and enhances the reliability and operation efficiency of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0038] Figure 1 This is the native Android binder communication architecture diagram;

[0039] Figure 2 This is the architecture diagram of the service distribution before the container service transformation;

[0040] Figure 3 This is a diagram of the novel cross-container communication binder architecture of the present invention;

[0041] Figure 4This is a service distribution architecture diagram after the container service sharing transformation of the present invention;

[0042] Figure 5 This is the incubator agent scheme diagram of the present invention. DETAILED DESCRIPTION

[0043] All features disclosed in this specification, or steps in all methods or processes disclosed, except mutually exclusive features and / or steps, can be combined in any manner.

[0044] Any feature disclosed in this specification (including any additional claims, abstract and drawings), unless otherwise stated, may be replaced by other equivalent or alternative features with similar purposes. That is, unless otherwise stated, each feature is only an example of a series of equivalent or similar features.

[0045] like Figure 3-Figure 5 As shown, a method for sharing services between Android containers of the present invention includes the following steps: creating multiple Android container instances in a host machine through container technology, and running a complete Android system in each container; allocating a private binder driver instance inside the container through binderfs inside each container, and the processes in the container communicate through this driver instance; extracting some sharable services from the container and running them in the host machine as public services; realizing communication between the container and the host machine public services through the binder driver that communicates across containers; and setting a public service manager in the host machine to manage the public services and register them to the host machine namespace.

[0046] like Figure 3 As shown in the figure, in order to achieve cross-container binder communication, we have implemented a new binder that can communicate across containers. After using this technology, the client process that originally used binder to call system services internally can call the actual external service without any difference from the original function.

[0047] Specifically, the host is provided with public service 1 and public service 2, which are managed and registered by the public service manager. The public service manager is responsible for registering these services in the host namespace and using the public binder driver ( / dev / public_binder, / dev / public_hwbinder,

[0048] / dev / public_vndbinder) to communicate with containers across containers. The host also includes the Docker engine, which is used to manage and run containers, and the operating system kernel and device drivers provide basic system functions and hardware support.

[0049] In container A, application 1 and internal service 1 are running and managed by the service management module. The services inside container A communicate through the / dev / binder driver. Application 1 and internal service 1 communicate internally through binder, and internal service 1 can process internal binder requests.

[0050] In container B, application 1 is also running, and it includes service 1 and service 2, which are managed by the service management module. The services inside container B also communicate through the / dev / binder driver. Unlike container A, container B sets up an external service agent to communicate with the public services in the host. Service 1 and service 2 communicate internally through binder, and communicate across containers with the public services in the host through the external service agent using the public binder driver.

[0051] Through this architecture, services in container A and container B can not only communicate internally through their own private binder drivers, but also communicate across containers with public services in the host through external service proxies and public binder drivers, thereby achieving service sharing and resource optimization. This design not only reduces the duplication of resources and improves the resource utilization efficiency of the system, but also enhances the stability and maintainability of the system.

[0052] like Figure 4 As shown in the figure, we extracted some services from the container and implemented them outside the container. Then, N services in the container were replaced by one proxy program. The services were stored in the proxy service process as threads, and the number of processes was significantly reduced. Since the proxy service can access external real services through the binder, there is no difference in functions. The number of program processes actually running on the real hardware is reduced, and resources are reduced.

[0053] like Figure 5 As shown in the figure, we move the incubator process (zygote family process) that occupies a relatively high amount of physical memory from the container to the outside of the host machine, using a technique called "laying eggs with a chicken". A lightweight zygote family process agent program (memory usage can be within 5M) is implemented inside the container to maintain the original communication between zygote and system services.

[0054] When the current zygote agent receives a request to incubate a process, it forwards it to the external zygote. It should be noted that after the external zygote is incubated, the process needs to be moved to the container's internal namespace, which is very different from native Android.

[0055] Specifically, the host machine and container A are managed and run through the Docker engine. The host machine includes a file system, operating system kernel, device drivers and hardware, providing basic system functions and hardware support.

[0056] In container A, system_server requests to create an application process, triggering the zygote64 agent. The zygote64 agent is responsible for communicating with the zygote64 process in the host. The zygote64 process in the host namespace has pre-loaded the JAVA virtual machine and public resources, waiting for the command to produce a new process. When the zygote64 agent of container A receives the request to create a process, it forwards the request to the zygote64 process in the host.

[0057] The zygote64 process in the host responds to the request, generates a new application process, and transfers the relevant information of the new process back to container A through namespace isolation technology. During the whole process, if the child process dies, the host will notify the zygote64 agent of container A to ensure the stability of the system and the effectiveness of process management.

[0058] The present invention reduces resource consumption within the container by centrally managing and incubating application processes in the host machine, improves the utilization efficiency of system resources and the speed of creating application processes, and ensures the stability of process management and operating system services between containers.

[0059] The following benefits can be obtained through the scheme of the present invention:

[0060] Effectively reduce resource expansion:

[0061] Taking the Android 13 environment as an example, the three incubator processes zygote, zygote64 and webview_zygote occupy 170M, 149M and 70M of physical memory respectively. When 5 Android container instances are virtualized, 398M*4=1558M can be saved. Even if the agent program is removed, more than 1G of physical memory can be saved, which is a significant benefit.

[0062] Taking the Android 13 Qualcomm Android image as an example, the number of native processes that can be extracted from a container is conservatively calculated to be 50, and the memory usage is 50*4=200M. In the scenario of opening 5 more containers, the physical memory can be reduced by 200M*4=800M, and the number of processes can be reduced by 195, which is a significant benefit.

[0063] The internal process responsibilities of the container are clearly divided, which is conducive to maintenance:

[0064] After the services are extracted, they are placed outside the container, and only necessary virtualized services are retained inside the container. The clear division of responsibilities helps with system maintenance and upgrades.

[0065] Reduce the size of container images:

[0066] Since the services extracted from the container can be merged into a lightweight process, the program binary size will be reduced. Reducing the size of the container image not only reduces the flash storage cost, but also reduces the bandwidth and time consumption when deploying the image.

[0067] Speed ​​up container image compilation:

[0068] Since the services extracted from the container can be merged into one process and the code is greatly reduced, the compilation speed is significantly accelerated.

[0069] As the demand for Android containerization technology increases, increasing the number of Android container instances that can be virtualized by specific hardware has become an important indicator that affects the competitiveness of enterprise products. In addition, with the upgrade of the Android operating system version, the demand for hardware gradually increases, and reducing container resource usage is an inevitable research direction. This solution reduces the resource sharing and utilization from the perspective of resource sharing, effectively reducing container resource usage;

[0070] The ultimate goal of the present invention is to retain only one main operating system service, and only retain the application and desktop program itself in each container. For example, Windows supports multiple users logging in at the same time: one operating system, multiple user sessions, and this overhead is much less than multiple Windows operating systems.

[0071] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that are not conceived through creative work should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope defined in the claims.

Claims

1. A method for sharing services between Android containers, It is characterized in that The following steps are involved: Step 1: Create multiple Android container instances in the host machine using container technology, and run a complete Android system in each container; Step 2: Allocate a private binder driver instance inside each container through binderfs, and the processes in the container communicate through this driver instance; Step 3: Extract some sharable services from the container and run them in the host as public services. Step 4: Use the binder driver for cross-container communication to realize communication between the container and the host public service; Step 5: Set up a public service manager in the host to manage public services and register them in the host namespace.

2. The method for sharing services between Android containers according to claim 1, Features: The public services include public service 1 and public service 2. / dev / public_binder, / dev / public_hwbinder, and / dev / public_vndbinder communicate with the container.

3. The method for sharing services between Android containers according to claim 1, Features: The public service manager in the host manages and coordinates cross-container communication between containers by registering public services, including registration and deregistration operations of services.

4. The method for sharing services between Android containers according to claim 1, Features: The service in the container communicates with the public service in the host machine through the proxy program. The proxy program replaces the original service process inside the container and accesses the public service through the binder driver of cross-container communication.

5. The method for sharing services between Android containers according to claim 1, Features: The public service manager is configured with a service discovery module for dynamically discovering and managing public services in the host machine.

6. The method for sharing services between Android containers according to claim 1, Features: The zygote process in the container is moved from the inside of the container to the outside of the host machine, and a lightweight zygote agent is implemented in the container. The zygote agent is used to maintain the communication between the zygote and the system service, including forwarding the request to create the process.

7. The method for sharing services between Android containers according to claim 1, Features: After the external zygote incubates the new process, the new process is transferred to the namespace inside the container through the namespace isolation technology.

8. The method for sharing services between Android containers according to claim 1, Features: The public service manager further includes a load balancing module for distributing public service requests among multiple container instances to optimize resource utilization and performance.

9. The method for sharing services between Android containers according to claim 1, Features: The host machine is provided with a log monitoring module for monitoring the running status of cross-container communication and public services to facilitate fault diagnosis and performance optimization.

10. The method for sharing services between Android containers according to claim 1, Features: Some service processes in the container are retained as needed and dynamically adjusted through configuration management tools to adapt to different workload requirements and improve system maintenance efficiency.

Citation Information

Cited By

  • Cross-container application fusion switching method of swan gap system

    CN121387445A