Php+mysql is really a combination of skin roughness and resistance.

Source: Internet
Author: User
Dormant for a long time, has been busy several major projects.

Several project content differ greatly from each other, but all of the payment and settlement parts have high precision requirements, one of which has a lot of real-time synchronization data.

How much to what extent? About an average of 30 update data per second, the 30 data, actually triggered 200 or so data comparison and update. Last year about 9, October in preparation for this project stage, I subjectively think php+mysql is very difficult to do this task, once on. NET, Java, Scala, Golang, and different databases, including pgsql, SQL Server, MongoDB has done a lot of research and test preparation, and then once chose the Scala program. But really hands-on time, static language characteristics, really let me have a lot of not adapt to the place, especially the servlet container, every update to reload?? Maybe I'm really spoiled by dynamic language.

In the first phase, I wrote some refactoring and improved code, so I decided to abandon the option of choosing a static language to transform the entire project. Because the online part of the system business is too large, and many business logic, the earlier development of PHP version, has been packaged is very robust and perfect, the only way to persuade me to change, only the language between the performance differences. After some comparisons, especially with the actual deployment updates of the servlet compared to the existing PHP, I made a comparison of the feature list, and each feature actually tested the servlet mode and PHP model comparisons, and ultimately decided to abandon the choice of static language to transform the entire project.

In the construction of the web system, PHP supports dynamic update is a very important feature, which may have become his differences in all the existing web development language, one of the biggest advantages. Ruby, node. js, Golang, Java, up to the template dynamic update, in release mode, the class library file is called to load in place of the mechanism, never released, or compiled into a binary file, pre-load.

Abandon the reconstruction of the scheme, it is necessary to change the thinking. The original idea is to use the web as the core of the system, the original purpose of the transformation is to make the Web more active to perform some operations and tasks of the function, so that he can initiate and carry out a number of tasks. But the actual situation, the first phase has been developed in PHP code, I do not want to destroy or refactor?? Because at the level of business logic, he has no problem. I can completely view the Web as a webservice point, the rest is to deploy multiple service points, the external data interface, and WebService docking, and by WebService to initiate the management and monitoring of these service.

The approximate scenario is like the following topology diagram:

Each external service contains only the minimal program logic that implements itself to perform the operation, and the core business logic is given to WebService. and service does not communicate between, do not need to know each other's existence, must do, arbitrarily add, arbitrarily deploy, update at any time. They are like the tentacles of the octopus, but have their own more specific functions and tasks, but they do not have the ability to think and judge, they are just accurate (especially can not be mistaken) to perform different tasks.

To determine this idea, I do not know exactly what his feasibility, the most important aspect of the environment is the capacity of WebService, this is the most uncertain. But with the advance of time, I have no more choice. External service section, I chose node. js because of the richness of NPM and my own familiarity with JS.

Service development is less difficult and quickly encapsulates a task scheduler and WebSocket Server. After a long period of intensive monitoring, the Task Scheduler's time delay, in an acceptable range, this point I know when I tested node. js, under the single-core conditions, under high-density pressure, he will not think directly to the CPU available computing capacity to use until full load.

Soon, the new service deployment is on-line, calibration data, WebService business logic tuning, these self-needless to say. What I have been worrying about is that the problems that may have happened on the webservice have not happened at all. Especially on the test server, that is just a most inexpensive server (that is, as long as his system crashes, I directly from the mirror reload), single-machine operation, incredibly no mess. Php+mysql's ability to withstand, really beyond my imagination, of course, because in advance on the capacity and computational capacity of the worry, for the characteristics of business logic, I also designed a multi-layered cache solution, so here also add memcache.

But these services, written in node. js, are really low in robustness and stability, often without stopping the service, and the scheduling and release of memory is not satisfactory. Of course, itself in the development of the service, I did not deliberately to optimize (basically can be described as rough), after all, there are many things have not been proven, there is no need to excessive exhausting cost brain. In my budget, this part is going to be reconstructed sooner or later?? The logic itself is also complex, and the final solution may not necessarily choose node. js.

Combined with the earliest research and testing, the service refactoring is now focused on the JVM and Golang. The JVM after so many years of Frost baptism, his memory management has been relatively perfect, and for its tuning experience and sharing, Google a search a lot of, can refer to the basis is also very much (then to Google Trends to see, this world all the development language inside, Java is far ahead), And I've already opened some code that was available. Golang is definitely a killer language, and I believe the language definitely has a higher performance than the JVM, but I'm really nervous about seeing his pointer sign, and his variables are polluting, and that's a bit of a hassle.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.