Method and system for on-demand generation of question instances on online platform
By starting a unique docker network for each user and reusing scenario-based question containers, the problems of resource waste and poor user experience in the existing technology are solved, and more efficient server resource utilization and user experience improvement are achieved.
Patent Information
- Application Number
- CN202410897361.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-10-11
AI Technical Summary
When a large number of users access the existing online network security platform, scenario-based question generation leads to a large amount of server resource waste, hot topics cannot be started in advance, and the user experience is poor.
By starting a unique docker network for each user, reusing scenario-based question containers, starting hot topics in advance or extending their shutdown time, reducing the number of container starts and resource usage.
Reduces server resource consumption and improves user experience, especially in situations of high concurrency and hot topics.
Smart Images

Figure CN118760495A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method and system for generating a question instance on demand on an online platform, belonging to the technical field of network security. Background Art
[0002] The online network security capability improvement platform is a SaaS platform that integrates practical training, competition, competition organization, and community. It provides competition resources and competition services for network security enthusiasts. In order to provide network security enthusiasts with a good user experience, the platform will provide users with scenario-based questions. Behind these scenario-based questions is the online target service, and the platform will dynamically generate targets based on the user's answering needs.
[0003] A typical online target service usually includes client browser, user authentication service, question bank service, dynamic question service and target scheduling service. Scenario-based questions provide users with interactive targets for penetration and breakthrough. Generally, the questions are made into a docker container image, the platform starts the docker container, and provides the user with access to the container.
[0004] The existing scenario-based question generation has the following problems: 1. Question resources cannot be reused. Each question of each user will correspond to a target. When thousands of people use the platform to answer questions, a large amount of server resources are required. As an online platform, users access it through the public network. The number of users accessing it every day is different. Each time a scenario question is started, a docker container must be started. Each docker container startup will occupy server resources. 2. For hot topics, the scenario-based question service is not started in advance, so users cannot use it right away, and the experience is poor. Summary of the invention
[0005] Purpose of the invention: In view of the problems existing in the above-mentioned prior art, the purpose of the present invention is to provide a method and system for generating question instances on demand on an online platform, provide a target reuse method to reduce the number of container startups, reduce operation and maintenance costs, and improve user experience.
[0006] Technical solution: To achieve the above-mentioned invention object, the present invention adopts the following technical solution:
[0007] A method for generating a question instance on demand on an online platform comprises the following steps:
[0008] When a user starts a scenario-based topic for the first time, a Docker network is started for the user. This Docker network is used as a unique network for the user to access Docker containers of different scenario-based topics.
[0009] If the scenario-based topic started by the user has a started Docker container instance with an idle connection, the user's Docker network will be connected to the scenario-based topic's Docker container. Otherwise, a new scenario-based topic Docker container will be started, and the user's Docker network will be connected to the newly started Docker container.
[0010] When the user closes the scenario-based topic, the user's Docker network is disconnected from the scenario-based topic Docker container;
[0011] When the user logs out of the platform or the user's Docker network is not connected to any scenario-based Docker container within the preset time, the user's Docker network is closed.
[0012] As a preference, create the user's Docker network through the instruction docker network create user network name; start the scenario-based theme container and connect to the user's Docker network through the instruction docker run-d --name title name --network user network name title image; start the scenario-based theme container through the instruction docker run-d --name title name title image; connect the container instance to the user's Docker network through the instruction docker network connect user network name title name.
[0013] As a preference, the docker network of the same user supports simultaneous connection to different scenario-based docker containers; the same scenario-based docker container supports simultaneous connection to different users' docker networks.
[0014] Preferably, the current number of connections of the docker container of the scenario-based topic is recorded in a database.
[0015] If the docker container of the scenario-based question has no user's docker network connection or has no user's docker network connection within the preset time, it will be closed and released.
[0016] Preferably, users access scenario-based questions on the online platform through the public network.
[0017] Preferably, the method further includes: determining a hot topic, if the number of visits to a scenario-based topic within a recent preset time period exceeds a preset threshold, it is determined to be a hot topic; the Docker container of the hot topic is started in advance, and / or the delayed shutdown time of the Docker container of the hot topic is extended.
[0018] A system for generating question examples on demand on an online platform, comprising:
[0019] The user network creation module is used to start a docker network for the user when the user starts the scenario-based topic for the first time. The docker network is used as a unique network for the user to access the docker containers of different scenario-based topics.
[0020] The topic access and exit module is used to connect the user's docker network to the docker container of the scenario-based topic when the user starts the scenario-based topic. If the scenario-based topic started by the user has a started docker container instance and an idle connection, otherwise, a new scenario-based topic docker container is started and the user's docker network is connected to the newly started docker container; and when the user closes the scenario-based topic, the user's docker network is disconnected from the scenario-based topic docker container.
[0021] The user network shutdown module is used to shut down the user's docker network when the user logs out of the platform or the user's docker network is not connected to any scenario-based docker container within a preset time.
[0022] A computer system includes a memory, a processor, and a computer program / instruction stored in the memory and executable on the processor. When the computer program / instruction is executed by the processor, the steps of a method for generating question instances on demand on an online platform are implemented.
[0023] A computer program product includes a computer program / instruction, which, when executed by a processor, implements the steps of a method for generating question instances on demand on an online platform.
[0024] Beneficial effects: Compared with the prior art, the present invention has the following advantages: 1. The present invention starts a unique docker network for each user to access docker containers of different scenario-based topics. By reusing scenario-based topics, the number of container startups is reduced, server resources are saved, and operation and maintenance costs are reduced. 2. The present invention obtains scenario-based hot topics through data analysis, and improves the user experience by pre-starting hot topics or delaying the release of hot topics. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 1 is an overall flow chart of an embodiment of the present invention, wherein (a) is a startup process and (b) is a shutdown process.
[0026] Figure 2 This is a schematic diagram of a user starting a first topic connection in an embodiment of the present invention.
[0027] Figure 3This is a schematic diagram of a second topic connection started by a user in an embodiment of the present invention.
[0028] Figure 4 This is a schematic diagram of connecting multiple users to multiple topics in an embodiment of the present invention.
[0029] Figure 5 This is a connection diagram of a newly started instance after the title instance reaches the maximum number of connections in an embodiment of the present invention. DETAILED DESCRIPTION
[0030] The technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings and specific embodiments.
[0031] like Figure 1 As shown, an embodiment of the present invention discloses a method for generating topic instances on demand on an online platform, which mainly includes: when a user starts a scenario-based topic for the first time, a docker network is started for the user, and the docker network is used as a unique network for the user to access the docker containers of different scenario-based topics; if the scenario-based topic started by the user has a started docker container instance and an idle connection, the user's docker network is connected to the docker container of the scenario-based topic, otherwise a new scenario-based topic docker container is started, and the user's docker network is connected to the newly started docker container; when the user closes the scenario-based topic, the user's docker network is disconnected from the scenario-based topic docker container; when the user logs out of the platform or the user's docker network is not connected to any scenario-based topic docker container within a preset time, the user's docker network is closed. If the docker container of the scenario-based topic is not connected to the user's docker network, it is closed and released, or it is closed and released after a period of time.
[0032] In the embodiment of the present invention, the docker network of the same user can be connected to multiple different scenario-based topic docker containers at the same time; the same scenario-based topic docker container can be connected to the docker networks of multiple different users at the same time.
[0033] like Figure 2 As shown, when a user starts a scenario topic for the first time, a docker network will be started for each user, and the network will be connected to the scenario topic docker container instance. The command example is as follows:
[0034] Create a network:
[0035] docker network create user01 network
[0036] Start the topic container A and connect to the network user 01 network:
[0037] docker run-d --name title A --network user 01 network title A image
[0038] When a user starts a scenario-based topic, the corresponding Docker container is connected to the user's unique network, which forms a scenario. When the user starts another topic, it is still connected to the user's unique network, which is equivalent to the same scenario. There is no new scenario, but only a node is added to the network of the current scenario.
[0039] like Figure 3 As shown, the user starts the second topic instance, and the topic container is directly connected to the user's exclusive network after it is started. The command example is as follows:
[0040] Start container B (without specifying a network):
[0041] docker run-d --name title B title B image
[0042] Connect container instance B to user01 network
[0043] docker network connect user01 network topic B
[0044] For example, the platform sets a scenario-based topic that can be reused by 5 users. If the scenario-based topic started by the user has spare connections, for example, only 4 user networks are connected to this scenario-based topic. Then the user's network can be directly connected to the docker container of this scenario-based topic.
[0045] like Figure 4 As shown, user 02 also wants to start topic B. If topic B has been started and has an idle connection, user 02's network directly connects to topic instance B, and there is no need to start a new topic instance. The command example is as follows:
[0046] Connect user 02 network to subject B instance:
[0047] docker network connect user02 network topic B
[0048] If there is no idle topic docker instance, that is, a started docker container, start a new docker container. This can reduce the number of scenario-based topic docker containers started and save time starting topic containers.
[0049] like Figure 5 As shown, if there is no idle connection in Topic B instance 1, user 02 will create a new topic instance if he wants to start Topic B.
[0050] When the user closes this scenario-based topic, the user's Docker network is disconnected from the topic's Docker container. After the disconnection, the database modifies the current number of connections of the topic's Docker container, for example, from 5 to 4. The next user can connect directly if he wants to open this topic.
[0051] If a user logs out of the platform, or the user's network is idle for 4 hours, that is, no docker container has been connected for more than 4 hours, the user's docker network will be automatically closed to save resources. The relevant command examples are as follows:
[0052] Check the network connection status regularly:
[0053] docker network inspect user network
[0054] If the user's network has no connection to the topic, the timer starts, and the network will be deleted after 4 hours:
[0055] docker network rm user network
[0056] In addition, in order to further improve the user experience, the platform sets up hot topic judgment. If the number of visits to a topic in recent days exceeds a certain value, it will be judged as a hot topic. When there is no connection to the Docker container of the hot topic, it will be closed after 4 hours to reduce the number of startups. Non-hot topics can be closed and released immediately when there is no user connection.
[0057] In actual application scenarios, the target scheduling service on the platform side will conduct data analysis based on the usage of platform questions, obtain hot scenario questions, and start the hot questions in the form of services in advance, so that most users can answer questions quickly and conveniently. On the user side, after logging in, the user browses the question bank and answers questions. If the question type selected by the user is a dynamic question (i.e., a scenario question) and this question is a hot question, the question bank service will directly return the link to the dynamic question. If the selected question is not a hot question, the target scheduling service will generate a new target or reuse an existing target according to the question information according to the aforementioned method of generating questions, thereby providing question services and returning question links.
[0058] Based on the same inventive concept, an embodiment of the present invention discloses a system for generating topic instances on demand on an online platform, comprising: a user network creation module, used to start a docker network for the user when the user starts a scenario-based topic for the first time, and the docker network is used as a unique network for the user to access the docker containers of different scenario-based topics; a topic access and exit module, used to connect the user's docker network to the docker container of the scenario-based topic when the user starts a scenario-based topic, if the scenario-based topic started by the user has an already started docker container instance and an idle connection, otherwise, a new scenario-based topic docker container is started and the user's docker network is connected to the newly started docker container; and when the user closes the scenario-based topic, the user's docker network is disconnected from the scenario-based topic docker container; a user network closing module, used to close the user's docker network when the user logs out of the platform or the user's docker network is not connected to any scenario-based topic docker container within a preset time.
[0059] A computer system disclosed in an embodiment of the present invention includes a memory, a processor, and a computer program / instruction stored in the memory and executable on the processor. When the computer program / instruction is executed by the processor, the steps of a method for generating question instances on demand on an online platform are implemented.
[0060] A computer program product disclosed in an embodiment of the present invention includes a computer program / instruction, which, when executed by a processor, implements the steps of a method for generating question instances on demand on an online platform.
Claims
1. A method for generating question instances on demand on an online platform, characterized in that: The steps include: When a user starts a scenario-based topic for the first time, a Docker network is started for the user. This Docker network is used as a unique network for the user to access Docker containers of different scenario-based topics. If the scenario-based topic started by the user has a started Docker container instance and an idle connection, the user's Docker network is connected to the scenario-based topic's Docker container. Otherwise, a new scenario-based topic Docker container is started, and the user's Docker network is connected to the newly started Docker container. When the user closes the scenario-based topic, the user's Docker network is disconnected from the scenario-based topic Docker container; When the user logs out of the platform or the user's Docker network is not connected to any scenario-based Docker container within the preset time, the user's Docker network is closed.
2. The method for generating question examples on demand on an online platform according to claim 1, characterized in that: Create the user's Docker network through the command docker network create user network name; start the scenario-based theme container and connect to the user's Docker network through the command docker run-d --name title name --network user network name title image; start the scenario-based theme container through the command docker run-d --name title name title image; connect the container instance to the user's Docker network through the command docker network connect user network name title name.
3. The method for generating question examples on demand on an online platform according to claim 1, characterized in that: The Docker network of the same user supports simultaneous connection to different scenario-based Docker containers; the same scenario-based Docker container supports simultaneous connection to different users’ Docker networks.
4. The method for generating question examples on demand on an online platform according to claim 1, characterized in that: The current number of connections of the Docker container of the scenario-based question is recorded in the database.
5. The method for generating question examples on demand on an online platform according to claim 1, characterized in that: If the docker container of the scenario-based question has no user's docker network connection or has no user's docker network connection within the preset time, it will be closed and released.
6. The method for generating question examples on demand on an online platform according to claim 1, characterized in that: Users access scenario-based questions on the online platform through the public network.
7. The method for generating question examples on demand on an online platform according to claim 1, characterized in that: The method also includes: determining a hot topic, if the number of visits to a scenario-based topic within a recent preset time period exceeds a preset threshold, it is determined to be a hot topic; the Docker container of the hot topic is started in advance, and / or, the delay shutdown time of the Docker container of the hot topic is extended.
8. A system for generating question examples on demand on an online platform, characterized in that: include: The user network creation module is used to start a docker network for the user when the user starts the scenario-based topic for the first time. The docker network is used as a unique network for the user to access the docker containers of different scenario-based topics. The topic access and exit module is used to connect the user's docker network to the docker container of the scenario-based topic when the user starts the scenario-based topic. If the scenario-based topic started by the user has a started docker container instance and an idle connection, otherwise, a new scenario-based topic docker container is started and the user's docker network is connected to the newly started docker container; and when the user closes the scenario-based topic, the user's docker network is disconnected from the scenario-based topic docker container. The user network shutdown module is used to shut down the user's docker network when the user logs out of the platform or the user's docker network is not connected to any scenario-based docker container within a preset time.
9. A computer system comprising a memory, a processor, and a computer program / instruction stored in the memory and executable on the processor, characterized in that: When the computer program / instructions are executed by a processor, the steps of a method for generating question instances on demand in an online platform are implemented according to any one of claims 1 to 7.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of a method for generating question instances on demand in an online platform are implemented according to any one of claims 1 to 7.
