Analysis and implementation of verification code recognition platform

Preamble:

The verification code recognition platform relies on the trained neural network model to predict unknown graphics, and the platform realizes api call billing and profit. In addition to a relatively complete neural network model, a verification code recognition platform must also have a website that can support the business. Architecture.

 

Due to the problem of high concurrency in the api direct adjustment method, it is not displayed when relying on the website server to directly realize the verification code recognition. At this time, it is necessary to introduce the concept of working machine and message queue:

 

message queue:

 

The message queue I use here is RabbitMQ ( https://www.rabbitmq.com/ ). Compared with traditional message queues, RabbitMQ adds the concept of Exchange (exchange), and supports multiple flexible rules such as direct and topic. Forward the message.

For a detailed introduction to RabbitMQ, please refer to this article: https://zhuanlan.zhihu.com/p/25069044

 

 

Working machine:

In fact, it is similar to the Quartz service we used before. The user verification code request is forwarded through the message queue and forwarded according to the rules, and then allocated to different servers dedicated to this business, because the identification verification code must be a high IO-intensive type of server. It will be very efficient to leave it to a professional.

 

 

To analyze the evolutionary history, we did this before the concept of caching:

 

The client requests come directly to the database, and the worker polls the database. First, multiple clients write to the database with high concurrency, which puts a lot of pressure on the database, and then the worker continuously queries the database to ensure the latest updates. The front desk also needs to rotate to get the latest news. This architecture seems to be a very failure.

 

Then, in order to solve the problem of excessive pressure at the database level, we introduced the No SQL database to alleviate the problem of high concurrent read and write, and used the multi-level cache architecture to support a large number of requests:

 

After the introduction, our pressure problem has been solved, and a new problem has come again. Because of network fluctuations, the client's request may not always fall on the database, and if the server goes down, the message is basically lost this time. , we want to achieve high availability without losing message persistence, so we introduce a message queue:

 

The feature of the message queue is that we can add our messages to the queue to realize asynchronous computing. RabbitMQ has the feature of message persistence. When the worker does not confirm the message, the message queue will think that you have not received the message. Next time It will be sent to the working machine again, and the working machine needs to answer it manually after the calculation, indicating that the message has been received.

 

So, now we have a general understanding of the basic process of the verification code recognition platform:

 

The message queue adopts the competition mode ( http://www.enterpriseintegrationpatterns.com/patterns/messaging/CompetingConsumers.html )

 

That is, the message will be competed by multiple working machines, and whoever gets the message belongs to whoever gets it, and other working machines cannot operate on the message.

 

In this way, the prototype of the verification code recognition platform is realized. I currently use java to implement such a platform. Currently, it can support the operation of the recognition computing business, but there are still many things missing. For example, it is a single-machine configuration, which is easy to cause a single point of failure. There is a lack of gateway to solve the problems of interface pressure and security, and whether the current popular TensorFlow has been introduced in computing, etc. I will continue to pay attention to this project, and welcome everyone to issue me.

 

GitHub:https://github.com/wade-zh/mbus

 

You can download the https://github.com/wade-zh/mbus/releases/tag/v1.0 version to test, I have already deployed the service.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325295581&siteId=291194637