tencent cloud

Feedback

How to Implement Concurrency Sharing

Last updated: 2024-01-26 12:00:38
    CAR allows you to flexibly allocate and share concurrencies so as to reduce costs.

    Option 1. Concurrency transfer

    CAR concurrencies are decoupled from applications. Assume that you have projects A and B and there is a pack of 100 concurrencies under project A. If project A is removed or does not need so many resources, you can unbind the concurrency pack from project A and transfer it to project B in the Projects page of the console at any time.
    
    
    

    Option 2. Multi-application projects

    CAR supports two types of projects as detailed in Appendix: Detailed description of project types.
    Single-application project: The project is associated with only one application. Concurrency packs under the project can be used by the application. The availability of resources is guaranteed, and you can enable the prelaunch feature to quickly load the application when a user connects to it.
    Multi-application project: Like a resource pool, concurrency packs under the project can be shared by all applications. When a user makes a request to connect to an application, idle concurrencies can be scheduled from the pool in real time.
    The following example shows how to use a multi-application project to implement concurrency sharing.
    1. Go to the Projects page in the console and create a multi-application project.
    
    
    
    2. In the Projects page, find the project and click Test under the Operation column. Then select the target applications to generate test passwords and save the generated information locally.
    3. Start a test. If you select the passwords generated for different applications, the corresponding applications will be started, but they all will use the concurrencies bound to the same project.
    
    
    
    Note:
    A test password is valid for seven days. Each time you click Test, a new password will be generated, but the previously generated passwords are still valid if they haven't expired.
    While a password is still valid, you don't need to generate a new one to perform operations such as purchasing a concurrency pack and updating the application version.
    4. If you want to integrate the SDK (for the integration demo and directions, see Step 3. Integrate CAR PaaS), when you call ApplyConcurrent to request a concurrency, you need to pass in both the ProjectId and ApplicationId parameters.
    Assume that the ID of the multi-application project is cap-abcdefgh and applications A (app-12345) and B (app-67890) need to share resources. Taking the integration demo for JavaScript as an example, you need to pass in the following parameters for the frontend of applications A and B respectively:
    //Application A
    
    const { data } = await axios.post(url, {
    ProjectId: 'cap-abcdefgh',
    ApplicationId: 'app-12345',
    UserId: 'user-id', //Random UserId
    ClientSession: TCGSDK.getClientSession(),
    });
    //Application B
    
    const { data } = await axios.post(url, {
    ProjectId: 'cap-abcdefgh',
    ApplicationId: 'app-67890',
    UserId: 'user-id', //Random UserId
    ClientSession: TCGSDK.getClientSession(),
    });

    Appendix: Detailed description of project types

    
    
    
    Project Type
    Description
    Main Strengths
    Use case
    Single-application
    The project is associated with only one application, and concurrency packs bound to the project can be used only by that application.
    When you call the ApplyConcurrent API to request a concurrency quota, you need to pass in the ProjectId parameter.
    You can enable the prelaunch feature to quickly load the application when a user connects to it.
    A virtual exhibition application requires at least 100 concurrencies and uses the prelaunch feature to allow users to quickly access the application without waiting for it to load.
    Multi-application
    Concurrency packs that are bound to the project are shared by all the applications under the project, but the prelaunch feature cannot be enabled.
    When you call the ApplyConcurrent API to request a concurrency, you need to pass in the ProjectId and ApplicationId parameters.
    Multiple applications can share concurrencies to reduce costs.
    Multiple exhibition applications which are independent of each other need to share the concurrency pool, so that each application can get idle concurrencies from the pool as needed when there are user access requests.
    Note:
    To maintain a balance between user experience and cost optimization, you can create a single-application project and a multi-application project and use them together:
    When there are user requests, you can first schedule the concurrencies in the single-application project. If prelaunch is enabled for the project, users can quickly use the application without waiting for it to load.
    When available concurrencies in the single-application project become insufficient (ApplyConcurrent() returns a prompt indicating that there are no idle concurrencies), you can then schedule concurrencies in the multi-application project.
    For more information, see Starting an Application and Queue Feature.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support