CN108829522A - A kind of method, apparatus and computer storage medium of concurrent access process - Google Patents
A kind of method, apparatus and computer storage medium of concurrent access process Download PDFInfo
- Publication number
- CN108829522A CN108829522A CN201810654705.3A CN201810654705A CN108829522A CN 108829522 A CN108829522 A CN 108829522A CN 201810654705 A CN201810654705 A CN 201810654705A CN 108829522 A CN108829522 A CN 108829522A
- Authority
- CN
- China
- Prior art keywords
- thread
- pool
- redis
- initializing
- processing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 31
- 238000010586 diagram Methods 0.000 description 3
- 238000003672 processing method Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 2
- 230000010365 information processing Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002688 persistence Effects 0.000 description 1
- 230000002085 persistent effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5083—Techniques for rebalancing the load in a distributed system
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
A kind of method, apparatus and computer storage medium of concurrent access process, including:For each thread in thread pool, long-range Dictionary server (Redis) connection pool in initialization thread is distinguished;By the thread in thread pool, the processing that is concurrently accessed;It wherein, include the thread of preset quantity in the thread pool.The embodiment of the present invention improves the stability and quality of concurrent access process.
Description
Technical Field
The present disclosure relates to, but not limited to, information processing technology, and more particularly, to a method, apparatus, and computer storage medium for concurrent access processing.
Background
In the internet field, a remote dictionary server (Redis, which is an open-source database written in ANSI C language, supporting network, a log-type and Key-Value database that can be based on memory and can also be persistent, and providing an Application Programming Interface (API) of multiple languages) is widely used in the industry as a very efficient non-relational database based on memory, because it provides efficient data read-write operation, and supports complex data structures such as string (string), linked list (list), set (set), hash (hash), etc.; in addition, Redis supports distributed master-slave deployment and expansion of the cluster, and provides data persistence modes of different levels, so that service expansion and cluster disaster tolerance are effectively guaranteed; meanwhile, Redis is also applied to scenarios such as subscription and publication, message queues, and the like.
In a high-frequency access service scene including shopping realized by c + +, higher requirements are put forward on multithreading high-concurrency data reading and writing of Redis. Currently, for high frequency access services, the following processing is generally performed: firstly, constructing a Redis connection pool, acquiring connection from the connection pool in a thread every time a request comes, and reading and writing data; in the scenario of the high concurrent access service, a client hiredis (a C interface of a Redis database) based on the C language may cause service crash, and affect the stability and quality of the concurrent access service.
Disclosure of Invention
The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
The embodiment of the invention provides a method and a device for concurrent access processing and a computer storage medium, which can improve the stability and the quality of the concurrent access processing.
The embodiment of the invention provides a method for concurrent access processing, which comprises the following steps:
respectively initializing a remote dictionary server Redis connection pool in the thread for each thread in the thread pool;
processing concurrent access through threads in the thread pool;
the thread pool comprises a preset number of threads.
Optionally, before initializing a Redis connection pool in a thread, the method further includes:
and initializing the thread pool when judging that the service is started.
Optionally, the method further includes:
each thread in the thread pool judges whether a Redis connection pool in the thread is connected or not when receiving a concurrent processing request in the thread;
and when judging that the Redis connection pool in the thread is not connected, re-initializing the Redis connection pool in the thread.
Optionally, before initializing a Redis connection pool in a thread, the method further includes:
and determining the number of threads in the thread pool according to the received external instruction.
On the other hand, an embodiment of the present invention further provides a device for concurrent access processing, including: connecting a pool initialization unit and a processing unit; wherein,
the connection pool initialization unit is used for: respectively initializing a remote dictionary server Redis connection pool in the thread for each thread in the thread pool;
the processing unit is used for: processing concurrent access through threads in the thread pool;
the thread pool comprises a preset number of threads.
Optionally, the apparatus further includes a thread pool initialization unit, configured to: and initializing the thread pool when judging that the service is started.
Optionally, the apparatus further includes a connection processing unit, configured to:
each thread in the thread pool judges whether a Redis connection pool in the thread is connected or not when receiving a concurrent processing request in the thread;
and when judging that the Redis connection pool in the thread is not connected, re-initializing the Redis connection pool in the thread.
Optionally, the apparatus further includes a determining unit, configured to: and determining the number of threads in the thread pool according to the received external instruction.
In still another aspect, an embodiment of the present invention further provides a computer storage medium, where computer-executable instructions are stored in the computer storage medium, and the computer-executable instructions are used to execute the method for concurrent access processing.
Compared with the related art, the technical scheme of the application comprises the following steps: respectively initializing a remote dictionary server (Redis) connection pool in the thread for each thread in the thread pool; processing concurrent access through threads in the thread pool; the thread pool comprises a preset number of threads. The embodiment of the invention improves the stability and quality of concurrent access processing.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the example serve to explain the principles of the invention and not to limit the invention.
FIG. 1 is a flow chart of a method of concurrent access processing according to an embodiment of the present invention;
fig. 2 is a block diagram of a concurrent access processing apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
Fig. 1 is a flowchart of a method for concurrent access processing according to an embodiment of the present invention, as shown in fig. 1, including:
step 101, respectively initializing a remote dictionary server (Redis) connection pool in a thread for each thread in a thread pool; the thread pool comprises a preset number of threads.
Optionally, before initializing a Redis connection pool in a thread, the method according to the embodiment of the present invention further includes:
and initializing the thread pool when judging that the service is started.
It should be noted that the method of initializing the thread pool and the connection pool may include a processing method that is customary to those skilled in the relevant art.
102, processing concurrent access through threads in a thread pool;
optionally, the method in the embodiment of the present invention further includes:
each thread in the thread pool judges whether a Redis connection pool in the thread is connected or not when receiving a concurrent processing request in the thread;
and when judging that the Redis connection pool in the thread is not connected, re-initializing the Redis connection pool in the thread.
Optionally, before initializing a Redis connection pool in a thread, the method according to the embodiment of the present invention further includes:
and determining the number of threads in the thread pool according to the received external instruction.
Compared with the related art, the technical scheme of the application comprises the following steps: respectively initializing a remote dictionary server (Redis) connection pool in the thread for each thread in the thread pool; processing concurrent access through threads in the thread pool; the thread pool comprises a preset number of threads. The embodiment of the invention improves the stability and quality of concurrent access processing.
Fig. 2 is a block diagram of a concurrent access processing apparatus according to an embodiment of the present invention, and as shown in fig. 2, the apparatus includes: connecting a pool initialization unit and a processing unit; wherein,
the connection pool initialization unit is used for: respectively initializing a remote dictionary server (Redis) connection pool in the thread for each thread in the thread pool;
the processing unit is used for: processing concurrent access through threads in the thread pool;
the thread pool comprises a preset number of threads.
Optionally, the apparatus in this embodiment of the present invention further includes a thread pool initialization unit, configured to: and initializing the thread pool when judging that the service is started.
Optionally, the apparatus in this embodiment of the present invention further includes a connection processing unit, configured to:
each thread in the thread pool judges whether a Redis connection pool in the thread is connected or not when receiving a concurrent processing request in the thread;
and when judging that the Redis connection pool in the thread is not connected, re-initializing the Redis connection pool in the thread.
Optionally, the apparatus in this embodiment of the present invention further includes a determining unit, configured to: and determining the number of threads in the thread pool according to the received external instruction.
The embodiment of the invention also provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used for executing the concurrent access processing method.
The method of the embodiment of the present invention is described in detail below by using application examples, which are only used for illustrating the present invention and are not used for limiting the protection scope of the present invention.
Application example
The application example of the invention simultaneously initializes the connection of the client in the thread to the Redis service when the thread pool is initialized, and isolates the access of different threads to the Redis connection pool. In normal service, each time a concurrent processing request arrives, whether the Redis connection is available is checked first, and a Redis connection pool needs to be reinitialized for unavailable connections. The application example method can isolate the influence of different thread accesses on the Redis connection pool, and improve the robustness and stability of the whole service.
The application example processing process of the invention comprises the following steps:
when the service is started, initializing a thread pool of a specified number of threads;
when each thread is initialized, a Redis connection pool in the thread is initialized at the same time;
in the thread, when each concurrent access request is processed, the validity of the connection obtained to the thread is checked first, and if the connection is disconnected, a Redis connection pool in the thread needs to be initialized again.
The application example of the invention can isolate the influence of different thread accesses on the Redis connection pool, and improve the robustness and stability of the whole service. Application example of the invention: firstly, initializing a thread pool with specified thread quantity when service is started; then initializing a Redis connection pool in the thread when the thread is initialized, and storing the Redis connection pool as thread private data; and finally, when the thread is normally served, checking whether the acquired Redis connection is effective or not every time a request is received, and if the connection is invalid, re-initializing. The method and the device simultaneously initialize the Redis connection pool in the thread when the application example thread is initialized, but not all threads share one Redis connection pool; when processing is requested, whether the acquired Redis connection is valid or not is checked firstly, and if the acquired Redis connection is invalid, the connection is re-established instead of re-establishing the Redis connection each time. The application example of the invention initializes the thread pool of the specified thread quantity when the service is started.
It will be understood by those skilled in the art that all or part of the steps of the above methods may be implemented by a program instructing associated hardware (e.g., a processor) to perform the steps, and the program may be stored in a computer readable storage medium, such as a read only memory, a magnetic or optical disk, and the like. Alternatively, all or part of the steps of the above embodiments may be implemented using one or more integrated circuits. Accordingly, each module/unit in the above embodiments may be implemented in hardware, for example, by an integrated circuit to implement its corresponding function, or in software, for example, by a processor executing a program/instruction stored in a memory to implement its corresponding function. The present invention is not limited to any specific form of combination of hardware and software.
Although the embodiments of the present invention have been described above, the above description is only for the convenience of understanding the present invention, and is not intended to limit the present invention. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.
Claims (9)
1. A method of concurrent access processing, comprising:
respectively initializing a remote dictionary server Redis connection pool in the thread for each thread in the thread pool;
processing concurrent access through threads in the thread pool;
the thread pool comprises a preset number of threads.
2. The method of claim 1, wherein prior to initializing a Redis connection pool within a thread, the method further comprises:
and initializing the thread pool when judging that the service is started.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
each thread in the thread pool judges whether a Redis connection pool in the thread is connected or not when receiving a concurrent processing request in the thread;
and when judging that the Redis connection pool in the thread is not connected, re-initializing the Redis connection pool in the thread.
4. The method of claim 1 or 2, wherein prior to initializing a Redis connection pool within a thread, the method further comprises:
and determining the number of threads in the thread pool according to the received external instruction.
5. An apparatus for concurrent access processing, comprising: connecting a pool initialization unit and a processing unit; wherein,
the connection pool initialization unit is used for: respectively initializing a remote dictionary server Redis connection pool in the thread for each thread in the thread pool;
the processing unit is used for: processing concurrent access through threads in the thread pool;
the thread pool comprises a preset number of threads.
6. The apparatus of claim 5, further comprising a thread pool initialization unit to: and initializing the thread pool when judging that the service is started.
7. The apparatus according to claim 6 or 7, further comprising a connection processing unit for:
each thread in the thread pool judges whether a Redis connection pool in the thread is connected or not when receiving a concurrent processing request in the thread;
and when judging that the Redis connection pool in the thread is not connected, re-initializing the Redis connection pool in the thread.
8. The apparatus according to claim 6 or 7, characterized in that the apparatus further comprises a determining unit for: and determining the number of threads in the thread pool according to the received external instruction.
9. A computer storage medium having stored therein computer-executable instructions for performing the method of concurrent access processing of any of claims 1-4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810654705.3A CN108829522A (en) | 2018-06-22 | 2018-06-22 | A kind of method, apparatus and computer storage medium of concurrent access process |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810654705.3A CN108829522A (en) | 2018-06-22 | 2018-06-22 | A kind of method, apparatus and computer storage medium of concurrent access process |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108829522A true CN108829522A (en) | 2018-11-16 |
Family
ID=64138029
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810654705.3A Pending CN108829522A (en) | 2018-06-22 | 2018-06-22 | A kind of method, apparatus and computer storage medium of concurrent access process |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108829522A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110300160A (en) * | 2019-06-14 | 2019-10-01 | 杭州爱科科技股份有限公司 | Data sharing method for embedded system |
CN113722078A (en) * | 2021-11-02 | 2021-11-30 | 西安热工研究院有限公司 | High-concurrency database access method, system and equipment based on thread pool |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050132335A1 (en) * | 2003-12-10 | 2005-06-16 | Jonathan Maron | Application performance tuning server-side component |
CN103605727A (en) * | 2013-11-19 | 2014-02-26 | 浪潮电子信息产业股份有限公司 | Connection pool based efficient multiuser database access optimization method and framework |
CN103841127A (en) * | 2012-11-21 | 2014-06-04 | 苏州易和物联信息技术有限公司 | Data receiving service realizing method in real-time positioning system |
CN104239365A (en) * | 2013-06-24 | 2014-12-24 | 北京新媒传信科技有限公司 | Database connection pool and method for acquiring links in database connection pool |
-
2018
- 2018-06-22 CN CN201810654705.3A patent/CN108829522A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050132335A1 (en) * | 2003-12-10 | 2005-06-16 | Jonathan Maron | Application performance tuning server-side component |
CN103841127A (en) * | 2012-11-21 | 2014-06-04 | 苏州易和物联信息技术有限公司 | Data receiving service realizing method in real-time positioning system |
CN104239365A (en) * | 2013-06-24 | 2014-12-24 | 北京新媒传信科技有限公司 | Database connection pool and method for acquiring links in database connection pool |
CN103605727A (en) * | 2013-11-19 | 2014-02-26 | 浪潮电子信息产业股份有限公司 | Connection pool based efficient multiuser database access optimization method and framework |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110300160A (en) * | 2019-06-14 | 2019-10-01 | 杭州爱科科技股份有限公司 | Data sharing method for embedded system |
CN113722078A (en) * | 2021-11-02 | 2021-11-30 | 西安热工研究院有限公司 | High-concurrency database access method, system and equipment based on thread pool |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105579971B (en) | The detection of express passway user's space RDMA resource error | |
US11275618B2 (en) | Method, device and medium for allocating resource based on type of PCI device | |
CN109710695B (en) | Transaction request validity identification and initiation method, device, equipment and medium | |
CN111880956B (en) | Data synchronization method and device | |
US11048422B2 (en) | Method, device, and computer readable storage medium for allocating access rights to data among storage processors | |
CN112363762B (en) | Fusion command processing method, system, device and medium | |
CN110580305A (en) | Method, apparatus, system, and medium for generating identifier | |
CN108829522A (en) | A kind of method, apparatus and computer storage medium of concurrent access process | |
US20200050785A1 (en) | Database record access through use of a multi-value alternate primary key | |
CN109062717B (en) | Data caching method, data caching system, data caching disaster tolerance method, data caching disaster tolerance system and data caching system | |
CN113886264A (en) | Embedded method, device, equipment and storage medium of distributed database | |
US8090769B2 (en) | Dynamically generating web contents | |
CN109743367B (en) | Service processing method and device, electronic equipment and readable storage medium | |
CN115174158B (en) | Cloud product configuration checking method based on multi-cloud management platform | |
CN107291628B (en) | Method and apparatus for accessing data storage device | |
CN111767114A (en) | Method and device for creating cloud host, computer system and readable storage medium | |
CN111367921A (en) | Data object refreshing method and device | |
US9519592B2 (en) | Stale pointer detection with overlapping versioned memory | |
CN115033350A (en) | Execution method and device of distributed transaction | |
US10061614B2 (en) | Resource management for untrusted programs | |
CN112383434A (en) | Interface simulation method and device for network request, electronic equipment and storage medium | |
CN111736869A (en) | Version updating method of server-side interface and calling method of server-side interface | |
CN111143327A (en) | Data processing method and device | |
CN112702735A (en) | Registration information service method, equipment and computer readable storage medium | |
US20100024038A1 (en) | Automatic and adjustable system and method for synchronizing security mechanisms in database drivers with database servers |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20181116 |
|
RJ01 | Rejection of invention patent application after publication |