CN112306811A - PHP micro-service control method, system, terminal and medium - Google Patents

PHP micro-service control method, system, terminal and medium Download PDF

Info

Publication number
CN112306811A
CN112306811A CN202011251426.6A CN202011251426A CN112306811A CN 112306811 A CN112306811 A CN 112306811A CN 202011251426 A CN202011251426 A CN 202011251426A CN 112306811 A CN112306811 A CN 112306811A
Authority
CN
China
Prior art keywords
service
php
micro
log
memory
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
Application number
CN202011251426.6A
Other languages
Chinese (zh)
Inventor
罗涛
黄宇扬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Yichong Technology Co ltd
Original Assignee
Chongqing Yichong Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Chongqing Yichong Technology Co ltd filed Critical Chongqing Yichong Technology Co ltd
Priority to CN202011251426.6A priority Critical patent/CN112306811A/en
Publication of CN112306811A publication Critical patent/CN112306811A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3006Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/32Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/324Display of status information
    • G06F11/327Alarm or error message display

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a PHP micro-service control method, a system, a terminal and a medium, wherein the method comprises the steps of obtaining a working log generated in the operation process of the PHP micro-service, storing the working log into a memory in real time, persisting the working log in the memory at intervals of preset time, and clearing the persistent working log in the memory; the invention also discloses a PHP micro-service control system, a terminal and a medium, which can solve the problems that the working log is written into a disk in real time for persistence, the storage time is longer, and the working efficiency of the micro-service is slowed down, and improve the storage efficiency of the working log and the working efficiency of the micro-service.

Description

PHP micro-service control method, system, terminal and medium
Technical Field
The invention relates to the technical field of computers, in particular to a PHP micro-service control method, a system, a terminal and a medium.
Background
With the development of science and technology, the micro service architecture is more and more widely applied.
However, the micro-service architecture also faces many challenges, for example, because a large amount of work logs are generated during the operation of the micro-service, the work logs are written into a disk in real time for persistence, the storage time is long, and the work efficiency of the micro-service is slowed down.
Disclosure of Invention
In view of the above drawbacks of the prior art, an object of the present invention is to provide a method, a system, a terminal and a medium for controlling a PHP microserver, which are used to solve the problems that a working log is written into a disk in real time for persistence, the storage time is long, and the working efficiency of the microserver is slowed down.
In order to achieve the above objects and other related objects, the present invention provides a PHP micro-service control method, including:
acquiring a work log generated in the PHP micro-service operation process, and storing the work log into a memory in real time;
and persisting the working log in the memory at preset intervals, and clearing the working log which is persisted in the memory.
Optionally, the method further includes:
and before the PHP micro-service system is closed, persisting the working log in the memory.
Optionally, after the working log is stored in the memory in real time and before the working log in the memory is persisted at the preset interval time, the method further includes:
and acquiring application request information corresponding to the working log, and determining a log label of the working log according to the application request information.
Optionally, the persisting the working log in the memory at the preset interval time includes:
determining a log storage path according to the log label;
and persisting the working log according to the log storage path.
Optionally, at least one of the following is also included:
acquiring the number of user requests in unit window time, and controlling a preset number threshold of user requests to access the PHP micro-service if the number of the user requests is larger than a preset number threshold;
if the PHP micro-service is in the running state, monitoring and reporting the service state of the PHP micro-service;
acquiring state information of a micro service node, and fusing service call of the micro service node if the state information meets a preset fusing condition;
the code of the PHP micro-service comprises annotation information, and an AOP proxy class is constructed according to the annotation information;
acquiring request content input by a user, and determining an application request corresponding to the request content in a multi-national language database according to the request content.
Optionally, if the PHP micro-service control method includes acquiring the number of user requests in a unit window time, and if the number of user requests is greater than a preset number threshold, controlling a preset number threshold number of users to request access to the PHP micro-service, where controlling the preset number threshold number of users to request access to the micro-service system includes:
acquiring and sequencing the priority of each user request, and determining the ranking, wherein the priority is determined according to at least one of the preset level of the user, the category of the user request, the access frequency of the user request, the attribution of the user and the waiting time of the user request;
and controlling the users with the preset number threshold value to request to access the PHP micro service.
The invention also provides a PHP micro-service system, which comprises:
the memory module is used for acquiring a working log generated in the PHP micro-service operation process and storing the working log into a memory in real time;
and the persistence module is used for persisting the working log in the memory at intervals of preset time and clearing the working log which is persisted in the memory.
Optionally, at least one of the following is also included:
the current limiting module is used for acquiring the number of user requests in unit window time, and controlling a preset number threshold of users to request to access the PHP micro-service if the number of the user requests is larger than a preset number threshold;
the monitoring module is used for monitoring and reporting the service state of the PHP micro-service if the PHP micro-service is in the running state;
the system comprises a fusing module, a judging module and a judging module, wherein the fusing module is used for acquiring state information of a micro service node, and fusing service calling of the micro service node if the state information meets a preset fusing condition;
the code of the PHP micro-service comprises annotation information and is used for constructing an AOP proxy class according to the annotation information;
and the multi-country language module is used for acquiring the request content input by the user and determining the application request corresponding to the request content in the multi-country language database according to the request content.
The invention also provides a terminal, which comprises a processor, a memory and a communication bus;
the communication bus is used for connecting the processor and the memory;
the processor is used for executing the computer program stored in the memory to realize the PHP micro-service control method according to one or more of the above embodiments.
The present invention also provides a computer-readable storage medium, having stored thereon a computer program,
the computer program is configured to cause the computer to execute the PHP microservice control method according to any one of the above embodiments.
As described above, the PHP micro-service control method, system, terminal and medium provided by the present invention have the following beneficial effects:
the method comprises the steps of obtaining a working log generated in the PHP micro-service operation process, storing the working log into a memory in real time, persisting the working log in the memory at intervals of preset time, and clearing the persistent working log in the memory. The problem that the working efficiency of the micro service is slowed down due to the fact that the working logs are written into a disk in real time for persistence and the storage time is long can be solved, and the efficiency of working log storage and the working efficiency of the micro service are improved.
Drawings
Fig. 1 is a schematic flowchart of a PHP microserver control method according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a PHP microservice applying the PHP microservice control method of fig. 1 according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a PHP microserver system according to a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention. It is to be noted that the features in the following embodiments and examples may be combined with each other without conflict.
It should be noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present invention, and the components related to the present invention are only shown in the drawings rather than drawn according to the number, shape and size of the components in actual implementation, and the type, quantity and proportion of the components in actual implementation may be changed freely, and the layout of the components may be more complicated.
Example one
Referring to fig. 1, an embodiment of the invention provides a method for controlling a PHP micro-service, including:
s101: and acquiring a working log generated in the PHP micro-service operation process, and storing the working log into a memory in real time.
Optionally, the working log includes, but is not limited to, a service log file generated by the micro service system application for an application request in response to any application request when the PHP micro service system application receives the application request, and the service log file includes, but is not limited to, a request link log.
Optionally, the working log is also collected into an SLS log management system to provide queries and visualizations.
Optionally, the work log comprises a request link log.
Optionally, the memory is preset, and the working log is stored into the memory in real time, so that on one hand, the working log is recorded, and on the other hand, compared with the working log which is directly stored in a disk and the like, the time required by storage can be reduced, and the working efficiency of the PHP micro-service is improved.
Optionally, the PHP microservice is based on a Swoole extension.
S102: and persisting the working log in the memory at preset intervals, and clearing the persistent working log in the memory.
Alternatively, the preset time may be any reasonable time length set by one skilled in the art according to needs, and is not limited herein.
Alternatively, the work logs temporarily stored in the memory may be stored in the disk at preset time intervals. It should be noted that, storing the working log into the memory and persistently storing the working log in the memory may be two parallel steps, that is, taking persistent storage of the working log in the memory at an interval of 30 seconds as an example, on one hand, persistent storage of the working log stored into the memory in the previous 30 seconds is performed, and on the other hand, the working log generated in real time is also stored into the memory in real time, and the two are independent programs, so that the response time brought by the system for actually storing the working log is the time required for writing into the memory, the IO time is greatly reduced, and the working efficiency of the PHP microservice is improved.
Optionally, the persistent working log is cleared, so that resource occupation can be reduced, and resource waste can be reduced.
Optionally, after the working log is stored in the memory in real time, before the working log in the memory is persisted at a preset time interval, the method further includes:
and acquiring application request information corresponding to the working log, and determining a log label of the working log according to the application request information.
If the working log includes at least one of a service log file and a request link log, the log tag may be determined by obtaining the application request information, where the application request information includes, but is not limited to, at least one of a user level, a request frequency, a request type, a user attribution, and the like of a user who made the application request.
Optionally, the corresponding work log can be conveniently and quickly found based on the log label.
Optionally, persisting the working log in the memory at a preset interval time includes:
determining a log storage path according to the log label;
and persisting the working log according to the log storage path.
Optionally, before the working log in the memory is made persistent, a mapping correspondence between the log label and the log storage path is preset, the log storage path is determined by the log label according to the mapping correspondence, and the working log in the memory is stored in the disk corresponding to the log storage path.
Optionally, the log persistence includes, but is not limited to, storing the log in a hard disk or a magnetic disk.
Optionally, the PHP micro-service control method further includes at least one of:
after the system is initialized and configured by pulling Apollo, acquiring an initial log component and a supplementary log component, performing adaptation processing on the initial log component according to a preset rule to generate an adapted log component, and packaging the adapted log component and the supplementary log component;
acquiring the number of user requests in unit window time, and controlling the users with the preset number threshold to request to access the PHP micro-service if the number of the user requests is larger than the preset number threshold;
if the PHP micro-service is in the running state, monitoring and reporting the service state of the PHP micro-service;
acquiring state information of the micro service node, and fusing service call of the micro service node if the state information meets a preset fusing condition;
the code of the PHP micro-service comprises annotation information, and an AOP proxy class is constructed according to the annotation information;
acquiring request content input by a user, and determining an application request corresponding to the request content in a multi-national language database according to the request content.
Optionally, the initial log component includes, but is not limited to, various existing log components, and since the existing log components cannot meet the requirements of the PHP microservice, a preset rule is determined according to the overall design idea of the current PHP microservice, the initial log component is generated and modified according to a preset rule,
optionally, the supplementary log component includes, but is not limited to, a log tag and log storage path mapping relation processing component, and the like.
Optionally, if the user request is not limited, the micro-service traffic may be too large, the system may be overloaded, or even the system may be crashed, so that the current may be limited according to the number of user requests in a unit window time, and the micro-service operation may be guaranteed to be normal.
It should be noted that the length of the unit window time may be set as needed. The preset number threshold may also be set by a person skilled in the art as desired and is not limited herein. The preset number threshold may be regarded as the maximum user request amount that the micro service system can accept, and therefore, when the number of user requests is greater than the preset number threshold, only a preset number threshold of users are allowed to request to access the PHP micro service.
Optionally, the step of controlling a preset number of threshold number of users to request access to the microservice system includes:
acquiring the priority of each user request, sequencing and determining the rank;
and controlling the users ranked at the top preset number threshold to request to access the PHP micro-service.
In some embodiments, when the number of user requests exceeds the maximum number that can be served by the microservice, then a portion of the user requests may need to be selectively allowed to access the microservice. The user request may be simply based on the occurrence time of the user request as a basis for determining whether to allow access to the microservice, for example, the user request occurs earlier and is preferentially allowed to access the microservice.
In some embodiments, the user's predetermined level is preset for each user making the user request, and whether to allow access to the microservice may also be determined according to the user's predetermined level, for example, the user's predetermined level is higher than the user's predetermined level to allow access to the microservice preferentially.
In some embodiments, the user requests may be sorted according to their priorities, and a threshold number of users with a top rank may be selected to request access to the microservice. The priority can be determined according to at least one of a preset level of the user, a category of the user request, a frequency of access requested by the user, and a home location of the user. When the priority parameters include two or more than two, the weighted average result of the parameters can be used as the basis for the priority ranking. For example, the priority is determined according to the access frequency requested by the user and the home location of the user, at this time, the assignment is performed in advance on each home location to obtain the home location assignment, the weight setting is performed on the access frequency requested by the user and the home location of the user respectively, assuming that the weight of the access frequency requested by the user is 80% and the weight of the home location of the user is 20%, at this time, the access frequency requested by the a user is 20 and the home location is 3, the weighted average result of the a user is 20 + 80% + 3% + 20% + 16.6, the access frequency requested by the B user is 5, and the home location is assigned 8, the weighted average result of the a user is 5 + 80% +8 + 20% + 5.6, and obviously, if the preset number threshold is 1, at this time, the a user is preferentially allowed to request to access the micro service.
In some embodiments, the priority is also determined based on a latency of the user request. Optionally, if the waiting time of a certain user request exceeds the waiting time threshold, the user request is preferentially scheduled to access the microservice. Alternatively, the latency threshold may be periodically updated based on historical latency. The historical wait time includes the wait time for a user request to give up access to occur.
Optionally, if the PHP microserver is in an operating state, the monitoring and reporting the service state of the PHP microserver includes:
if the PHP micro-service is in the running state, monitoring and reporting the service state of the PHP micro-service in real time;
or the like, or, alternatively,
and if the PHP micro-service is in the running state, monitoring in real time and reporting the service state of the PHP micro-service regularly.
Optionally, the service status is reported to Prometheus.
Optionally, if the service state is abnormal, an alarm signal is sent out. The alarm signal includes but is not limited to pushing prompt information to a preset terminal, giving a prompt tone and the like.
Optionally, the preset fusing condition includes, but is not limited to, a response time of the micro service node exceeding a preset response time, a failure of requesting an external system, and the like.
Optionally, the service call of the blown micro service node includes, but is not limited to, suspending the service of the micro service node.
Optionally, when the melting point condition of the micro service node is removed or the service suspension duration of the micro service node exceeds the preset service suspension duration, the fusing of the micro service node may be removed, and the service of the micro service node is resumed.
Alternatively, the fusing of the microservice node may be implemented based on a fuse.
Optionally, when the microservice system is constructed, an annotation may be set in a specific code according to needs, and an AOP proxy class may be constructed according to annotation information.
Optionally, the PHP microservice may support multilingual access by adding a multilingual database to the PHP microservice.
Fig. 2 is an example of a PHP micro-service to which the PHP micro-service control method according to the embodiment of the present invention is applied, where the PHP micro-service includes a global lifetime, a session period (a running period), and a service termination period. Referring to fig. 2, examples of the PHP microservice include:
s200: and starting.
S201: and (5) initializing the system.
Optionally, the system initialization comprises container initialization.
S202: and pulling the Apollo configuration.
Optionally, the Apollo configuration module may adopt an open source component, which is not limited herein.
Optionally, an Apollo configuration management platform is further provided, and the Apollo configuration management platform is used for uniformly managing configuration information of the corresponding environment pulled from the Apollo when the framework is started.
S203: the log component is initialized.
Optionally, initializing the log component includes obtaining the initial log component and supplementing the log component, performing adaptation processing on the initial log component according to a preset rule to generate an adapted log component, and packaging the adapted log component and the supplementing log component.
The initial log component includes, but is not limited to, various existing log components, and since the existing log components cannot meet the requirements of the PHP microservice, the preset rules are determined according to the overall design idea of the current PHP microservice, the initial log component is generated and modified according to the preset rules,
optionally, the supplementary log component includes, but is not limited to, a log tag and log storage path mapping relation processing component, and the like.
S204: the code annotation information is scanned.
Optionally, when creating a code of the PHP microservice, adding an annotation to a specific agent according to a certain rule, and then scanning the agent annotation information to obtain an annotation on the code.
S205: and constructing the AOP proxy class according to the annotation.
Optionally, according to the annotation obtained in step S204, an AOP (Aspect organized Programming) proxy class may be constructed.
Unified maintenance of program functions can be realized through the AOP proxy class.
S206: boottraper bootstrap hooks are executed.
Optionally, the service realized by the extended microservice can be realized based on the boottraper bootstrap hook, and the service decoupling is realized.
S207: the Swoole related callbacks are configured.
Optionally, the relevant manner of this step may be implemented by using the existing relevant technology, and is not described herein again.
S208: the service is started.
S209: register the service with Consul.
Optionally, the relevant manner of this step may be implemented by using the existing relevant technology, and is not described herein again.
Optionally, after the service is successfully registered with the Consul, the PHP microserver enters the operation period.
Optionally, when the service is started, the service is registered in the service registration center, and may be provided for other services to perform service discovery.
S210: user traffic enters.
S211: a network request is received.
Optionally, the network request is transmitted based on the HTTP protocol.
Optionally, the network request, that is, the user request, includes user information for sending the user request. The user information includes, but is not limited to, at least one of a user's rank, home, user identification information, and the like.
S212: and matching the routes.
S213: and (6) limiting the current.
Optionally, the number of user requests in unit window time is obtained, and if the number of user requests is greater than a preset number threshold, the number of user requests with the preset number threshold is controlled to access the PHP microservice.
Specifically, the user requests may be sorted according to the priority of the user requests, and then the users ranked at the top preset number threshold are selected to request to access the microservice. The priority can be determined according to at least one of a preset level of the user, a category of the user request, a frequency of access requested by the user, and a home location of the user. When the priority parameters include two or more than two, the weighted average result of the parameters can be used as the basis for the priority ranking.
Alternatively, this step may be implemented based on a flow restrictor.
Overload of the system can be prevented by limiting the current.
S214: request link log (opentracking) is recorded.
Optionally, the work log comprises a request link log.
Optionally, the recording the request link log includes:
acquiring a request link log generated in the PHP micro-service operation process, and storing the request link log into a memory in real time;
and persisting the request link log in the memory at preset intervals, and clearing the persisted request link log in the memory.
Optionally, the request link log is also collected into an SLS log management system to provide querying and visualization. Optionally, the SLS log management system comprises alisporus SIS.
Optionally, the method further includes step S219: request link logs are collected to the Alice cloud SIS.
Optionally, the memory is preset.
Alternatively, the preset time may be any reasonable time length set by one skilled in the art according to needs, and is not limited herein.
Optionally, the request link log temporarily stored in the memory may be stored in the disk at preset time intervals. It should be noted that, storing the request link log into the memory and persisting the working log in the memory may be two parallel steps, and optionally, the persistent working log is cleared, so that resource occupation may be reduced, and resource waste may be reduced.
Optionally, after the request link log is stored in the memory in real time, before the request link log in the memory is persisted at preset time intervals, the method further includes:
and acquiring application request information corresponding to the request link log, namely information requested by a network or a user, and determining a log label of the request link log according to the application request information.
The application request information includes, but is not limited to, at least one of a user level, a frequency of requests, a category of requests, a user's home location, etc. of a user making the application request.
Optionally, persisting the request link log in the memory at a preset interval time includes:
determining a log storage path according to the request link label;
and persisting the request link log according to the request link storage path.
Optionally, before persisting the request link log in the memory, a mapping correspondence between the log tag and the log storage path is preset, the log storage path is determined by the log tag according to the mapping correspondence, and the request link log in the memory is stored in a disk corresponding to the log storage path.
S215: other services are accessed.
Optionally, the user request may include a request for accessing other micro-services, and the micro-service node may access other services that the user request needs to access.
Optionally, accessing other services may be based on step S220: using Consul service discovery.
S216: fusing, degrading logic.
Optionally, the state information of the micro service node may be acquired, and if the state information meets a preset fusing condition, the service call of the micro service node is fused. For example, when a request for an external system fails, fuse logic is triggered, and when a recovery is requested after a period of time, the fuses are closed.
Alternatively, the destaging logic may be implemented based on existing destaging logic, and will not be described herein.
S217: and responding to the request.
Optionally, responding to the request comprises responding to a user request.
S218: and reporting the service state to Prometheus periodically.
Alternatively, the service status may be reported to a Prometheus monitoring alarm system.
Optionally, the reported service status may be viewed in Prometheus.
S221: and if the service state is abnormal, giving an alarm.
S222: a service close command is received.
Optionally, when receiving the service close command, the PHP microserver enters the service termination period.
Optionally, after receiving the service close command and before closing the service, the method further includes:
and persisting the request link log in the current memory.
S223: logging off the current service to Consul.
S224: the marking service is closed and traffic is rejected.
S225: waiting for the existing request to be processed.
S226: the service is closed.
S227: and (6) ending.
The embodiment of the invention provides a PHP micro-service control method, which comprises the steps of acquiring a work log generated in the running process of the PHP micro-service, storing the work log into a memory in real time, persisting the work log in the memory at intervals of preset time, and clearing the work log which is persisted in the memory. The problem that the working efficiency of the micro service is slowed down due to the fact that the working logs are written into a disk in real time for persistence and the storage time is long can be solved, and the efficiency of working log storage and the working efficiency of the micro service are improved.
Example two
Referring to fig. 3, an embodiment of the invention provides a PHP microserver system 300, including:
the memory module 301 is configured to obtain a work log generated in the running process of the PHP micro-service, and store the work log into a memory in real time;
the persistence module 302 is configured to persist the working log in the memory at preset time intervals, and clear the persistent working log in the memory.
Optionally, the PHP micro-service system further includes at least one of:
the current limiting module is used for acquiring the number of user requests in unit window time, and controlling the users with the preset number threshold to request to access the PHP micro-service if the number of the user requests is larger than the preset number threshold;
the monitoring module is used for monitoring and reporting the service state of the PHP micro-service if the PHP micro-service is in the running state;
the fusing module is used for acquiring the state information of the micro service node, and fusing the service call of the micro service node if the state information meets the preset fusing condition;
the code of the PHP micro-service comprises annotation information and is used for constructing an AOP proxy class according to the annotation information;
and the multi-country language module is used for acquiring the request content input by the user and determining the application request corresponding to the request content in the multi-country language database according to the request content.
Optionally, the PHP microserver system further includes a link tracking module, configured to obtain participation service information responding to the user request, and a participation sequence of each service, and generate a request link log.
Optionally, the PHP microservice system further includes a service registration and discovery module, configured to register a service and discover the service.
Optionally, the PHP micro-service system provided in this embodiment uses a PHP technology stack, and for a user who originally uses a single-body architecture system, the micro-service architecture can be used to perform separate treatment on each service block in the single-body architecture on the basis of keeping the original PHP technology stack, so as to solve the problem that the single-body architecture is not enough to support diversified service requirements. The coupling degree is high, the availability is low, the maintenance cost is high, the expansion and contraction can not be performed according to the requirement, and the like, so that the development cost is reduced.
Optionally, the PHP micro-service system provided in this embodiment may be implemented by using an EFrame, and may implement migration of services from a single framework to a micro-service framework, and through a system framework with service splitting, easy maintenance, unlimited technology stack, and expansion and contraction as needed, the original PHP technology stack is still maintained after migration, so as to reduce personnel use cost, and provide better support for services of each plate.
Optionally, the PHP micro-service system provided in this embodiment runs a framework in a resident memory mode based on a Swoole extension, and combines at least one of the open source technical scheme Apollo, Jwt authority authentication, Kong, Oss, Mns, K8S, Consul, Prometheus, and SLS log system through an event module, a link tracking module, an AOP agent module, an object pool, a current limiter, a fuse module, a downgrade module, a monitoring module, a log component, a multinational language module, and a service registration and discovery module, so as to implement service administration, current limiting & fusing, unified configuration management, unified gateway, and system monitoring. Therefore, the scheme can form a whole set of micro-service solution based on the PHP technology stack.
In this embodiment, the PHP micro-service system is substantially provided with a plurality of modules for executing the PHP micro-service control method of the first embodiment, and specific functions and technical effects are only required by referring to the first embodiment, which is not described herein again.
Referring to fig. 4, an embodiment of the present invention further provides a terminal 400, which includes a processor 401, a memory 402, and a communication bus 403;
the communication bus 403 is used to connect the processor 401 and the memory 402;
the processor 401 is configured to execute the computer program stored in the memory 402 to implement the PHP microservice control method according to one or more of the first embodiment.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored thereon, and the computer program is configured to enable the computer to execute the PHP micro-service control method according to any one of the above embodiments.
Embodiments of the present application also provide a non-transitory readable storage medium, where one or more modules (programs) are stored in the storage medium, and when the one or more modules are applied to a device, the device may execute instructions (instructions) included in an embodiment of the present application.
It should be noted that the computer readable medium mentioned above in the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
Computer program code for carrying out operations for disclosed herein may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or change the above-mentioned embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.

Claims (10)

1. A PHP micro-service control method is characterized by comprising the following steps:
acquiring a work log generated in the PHP micro-service operation process, and storing the work log into a memory in real time;
and persisting the working log in the memory at preset intervals, and clearing the working log which is persisted in the memory.
2. The PHP microservice control method of claim 1, further comprising:
and before the PHP micro-service system is closed, persisting the working log in the memory.
3. The PHP microserver control method according to claim 1, wherein after storing the working log in the memory in real time and before persisting the working log in the memory at the preset interval time, the method further comprises:
and acquiring application request information corresponding to the working log, and determining a log label of the working log according to the application request information.
4. The PHP micro-service control method according to claim 3, wherein the persisting the working log in the memory at the interval of the preset time comprises:
determining a log storage path according to the log label;
and persisting the working log according to the log storage path.
5. The PHP microservice control method of any one of claims 1-4, further comprising at least one of:
acquiring the number of user requests in unit window time, and controlling a preset number threshold of user requests to access the PHP micro-service if the number of the user requests is larger than a preset number threshold;
if the PHP micro-service is in the running state, monitoring and reporting the service state of the PHP micro-service;
acquiring state information of a micro service node, and fusing service call of the micro service node if the state information meets a preset fusing condition;
the code of the PHP micro-service comprises annotation information, and an AOP proxy class is constructed according to the annotation information;
acquiring request content input by a user, and determining an application request corresponding to the request content in a multi-national language database according to the request content.
6. The PHP micro-service control method of claim 5, wherein if the PHP micro-service control method includes obtaining a number of user requests in a unit window time, if the number of user requests is greater than a preset number threshold, controlling a preset number threshold number of users to request access to the PHP micro-service, and the controlling the preset number threshold number of users to request access to the micro-service system includes:
acquiring and sequencing the priority of each user request, and determining the ranking, wherein the priority is determined according to at least one of the preset level of the user, the category of the user request, the access frequency of the user request, the attribution of the user and the waiting time of the user request;
and controlling the users with the preset number threshold value to request to access the PHP micro service.
7. A PHP microserver system, comprising:
the memory module is used for acquiring a working log generated in the PHP micro-service operation process and storing the working log into a memory in real time;
and the persistence module is used for persisting the working log in the memory at intervals of preset time and clearing the working log which is persisted in the memory.
8. The PHP microserver system of claim 7, further comprising at least one of:
the current limiting module is used for acquiring the number of user requests in unit window time, and controlling a preset number threshold of users to request to access the PHP micro-service if the number of the user requests is larger than a preset number threshold;
the monitoring module is used for monitoring and reporting the service state of the PHP micro-service if the PHP micro-service is in the running state;
the system comprises a fusing module, a judging module and a judging module, wherein the fusing module is used for acquiring state information of a micro service node, and fusing service calling of the micro service node if the state information meets a preset fusing condition;
the code of the PHP micro-service comprises annotation information and is used for constructing an AOP proxy class according to the annotation information;
and the multi-country language module is used for acquiring the request content input by the user and determining the application request corresponding to the request content in the multi-country language database according to the request content.
9. A terminal comprising a processor, a memory, and a communication bus;
the communication bus is used for connecting the processor and the memory;
the processor is configured to execute the computer program stored in the memory to implement the PHP microservice control method of one or more of claims 1-6.
10. A computer-readable storage medium, having stored thereon a computer program,
the computer program is for causing the computer to execute the PHP microservice control method of any one of claims 1-6.
CN202011251426.6A 2020-11-09 2020-11-09 PHP micro-service control method, system, terminal and medium Pending CN112306811A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011251426.6A CN112306811A (en) 2020-11-09 2020-11-09 PHP micro-service control method, system, terminal and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011251426.6A CN112306811A (en) 2020-11-09 2020-11-09 PHP micro-service control method, system, terminal and medium

Publications (1)

Publication Number Publication Date
CN112306811A true CN112306811A (en) 2021-02-02

Family

ID=74325692

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011251426.6A Pending CN112306811A (en) 2020-11-09 2020-11-09 PHP micro-service control method, system, terminal and medium

Country Status (1)

Country Link
CN (1) CN112306811A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112906009A (en) * 2021-03-09 2021-06-04 南昌华勤电子科技有限公司 Work log generation method, computing device and storage medium
CN113849126A (en) * 2021-09-01 2021-12-28 北京腾凌科技有限公司 Log storage method and device
WO2023116827A1 (en) * 2021-12-23 2023-06-29 深圳市世强元件网络有限公司 High-concurrency data storage method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040128470A1 (en) * 2002-12-27 2004-07-01 Hetzler Steven Robert Log-structured write cache for data storage devices and systems
CN106850782A (en) * 2017-01-17 2017-06-13 泰康保险集团股份有限公司 For the method and system of log processing
CN107919987A (en) * 2017-11-16 2018-04-17 国云科技股份有限公司 A kind of implementation method of micro services cloud deployment
CN108847989A (en) * 2018-06-29 2018-11-20 杭州安恒信息技术股份有限公司 Log processing method, business service system and electronic equipment based on micro services framework
CN109408207A (en) * 2018-09-20 2019-03-01 北京小米移动软件有限公司 Micro services access control method, device and storage medium
CN109446174A (en) * 2018-10-30 2019-03-08 东软集团股份有限公司 Logdata record method, apparatus and computer readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040128470A1 (en) * 2002-12-27 2004-07-01 Hetzler Steven Robert Log-structured write cache for data storage devices and systems
CN106850782A (en) * 2017-01-17 2017-06-13 泰康保险集团股份有限公司 For the method and system of log processing
CN107919987A (en) * 2017-11-16 2018-04-17 国云科技股份有限公司 A kind of implementation method of micro services cloud deployment
CN108847989A (en) * 2018-06-29 2018-11-20 杭州安恒信息技术股份有限公司 Log processing method, business service system and electronic equipment based on micro services framework
CN109408207A (en) * 2018-09-20 2019-03-01 北京小米移动软件有限公司 Micro services access control method, device and storage medium
CN109446174A (en) * 2018-10-30 2019-03-08 东软集团股份有限公司 Logdata record method, apparatus and computer readable storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112906009A (en) * 2021-03-09 2021-06-04 南昌华勤电子科技有限公司 Work log generation method, computing device and storage medium
CN113849126A (en) * 2021-09-01 2021-12-28 北京腾凌科技有限公司 Log storage method and device
WO2023116827A1 (en) * 2021-12-23 2023-06-29 深圳市世强元件网络有限公司 High-concurrency data storage method and system

Similar Documents

Publication Publication Date Title
CN112306811A (en) PHP micro-service control method, system, terminal and medium
CN107590001B (en) Load balancing method and device, storage medium and electronic equipment
EP3418877A1 (en) Data writing and reading method and apparatus, and cloud storage system
JP5635763B2 (en) Method, apparatus and computer program for managing data integrity and data accuracy of information services using distributed data replicas
CN112261172B (en) Service addressing access method, device, system, equipment and medium
CN109905431B (en) Message processing method and system, storage medium and electronic equipment
US10425475B2 (en) Distributed data management
CN111258627A (en) Interface document generation method and device
CN112565334B (en) Access method and device of Internet of things equipment and MQTT gateway
CN110321252B (en) Skill service resource scheduling method and device
CN112395107A (en) Tax control equipment control method and device, storage medium and electronic equipment
CN115803714A (en) Dispatching tasks and data using multiple access edge computation
CN109428926B (en) Method and device for scheduling task nodes
KR102601628B1 (en) Resource processing methods and systems, storage media, electronic devices
CN113177179B (en) Data request connection management method, device, equipment and storage medium
CN114327710A (en) Function management method, management device, terminal equipment and readable storage medium
CN113765871A (en) Fortress management method and device
CN112148320A (en) Application program upgrading method, device, equipment and storage medium
JP5348907B2 (en) Service monitoring system and method
CN111091899B (en) Authority allocation method and device, electronic equipment and computer readable storage medium
KR101146742B1 (en) METHOD OF DISTRIBUTED SESSION MANAGEMENT IN SaaS AND SESSION MANAGEMENT SYSTEM THEROF
CN111400060A (en) Equipment linkage method, device, server and medium
CN113032576B (en) Knowledge graph management method, device, equipment and storage medium
CN112306701A (en) Service fusing method, device, equipment and storage medium
CN114449002B (en) Rendering node-based distributed deployment management method and device, electronic equipment and storage medium

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20210202