Introduce myself. I used to be a.NET programmer. In the second half of last year, I was in charge of transferring the project from.NET to Java.

8 years working as an architect, not in management, not as a tech guru, not as a sharing guru. Always doing business and going further and further down the road. Sometimes it feels awkward, but other times it feels right for you. Before the Spring Festival, my wife gave birth to a small public event. The baby is hungry, “the wife is quick to feed!” , the baby is hungry again, “the wife is quick to feed!” , the baby woke up and hungry, “the wife quickly to feed!” … Wife: “I feel like a cow!” As a “dad”, feeling quite profound! Your own project is like your own child, and when something happens to your child, the first thing people think about is this dad. Dad on duty (often getting up in the middle of the night), diaper change (server failure), feeding when needed (bug). If fall ill, feed medicine, take medicine regardless of use, ask a doctor outside (difficult miscellaneous disease, do not know, ask others to fix is also fix). Baby milk powder if there is a problem, I would like to take the knife to kill the profiteer (call other people’s service, service hung, affecting their own). Baby eat enough to drink, quiet sleep, dad can also feel at ease to sleep!

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — began to dry, below to record your own “parenting” result: 1. As mentioned at the beginning, I was a C# programmer before, the syntax of C# is subtle, the ide is awesome,.net version updates quickly, so fast that I can’t remember the latest version number. With all these new features, what good will it do us if we always have.net3.5 installed on the server? The beginning is very resistant to Java, off and on to learn many times did not put into use, this must go up. I have to say that over the years, Java has grown, stabilized, matured, solved almost any problem, and performed well. Over the past half a year, Java’s water is really deep, asynchronous, parallel and so on, I have not touched a lot of. The benefits of go will not be said, in learning, if you like and feel that you can hold, go on (ha, certainly not as easy as said). Nodejs is too convenient for the front-end, and some people use it for the server-side interface layer. PHP front-end pages, just like the server with Java, versatile, mature, stable, with more people, more data. In a word, there is no best, only the most suitable! Java was chosen because many of our microservices on the back end were also developed in Java for easy invocation. And what else can you do without Java? Storage: mysql, mongodb, Redis When the branch library can not solve the problem, the branch table is particularly important, there is a sense of infinite expansion. Oracle used before, only sub – library, no sub – table, can not hold. The type of storage or as little as possible, the better, Redis do cache is generally around the past, have to use. There are a lot of people on the team who hate mongodb, not to mention the specific reasons, but don’t use mongodb if Redis can handle it. Again, there is no best, only suitable, put the corresponding data in the most suitable storage. Mq: RabbitMQ, ActivemQ You will definitely use MQ, if not now, certainly in the future. Java framework: Spring MVC is used by many people, mature, pit has been stepped on by everyone, encountered problems easy to find information to solve. Ibatis and Struts were not used in our project.

Two. Source code management tool language selection, framework selection, to start to write code, the problem comes, write good code with what management? Git! SVN! Git branches can really solve so many problems. They are powerful! SVN tag is also good for publishing.

No matter what tool you use, make sure you have a good specification, such as git branch naming. Over time, there are more and more branches, and if you don’t standardize it, it’s a mess. Another example is branch merging, how should merge, how should not merge. Branch flow, which branch to submit tests to, which branch to publish, etc. The conflict resolution of branch merge must be communicated well in advance, otherwise the code will be lost and it will be difficult to find.

Monitoring is so important that you have to think about it from the beginning, otherwise it will be painful to add later. If you’re going to use a framework like Hystrix, you have to figure out how to implement it in the beginning, too. 2. Code specification architects always want to be perfect at the beginning, but if they don’t do the specification, there will be too many people back and forth, and the inside will be chaotic. Of course, even if you do the specification, it’s going to be messy, but it’s going to be messy. 3. Some basic codes such as: log, HTTP request, how to add monitoring, how to call RPC, interface online document query, etc. 4. After debugging code is written, how to run, how to debug, whether to use Jetty or Tomcat locally, how to publish the test server, all these need to be adjusted according to the actual situation. For Java, some people like Eclipse and some people like IDEA. For example, git management tools, some people like sourcetree, others like to type commands, it is more difficult to unify. Take a look at any code your colleagues have written, put it in the right place, and duplicate it. Don’t clutter up your shelf. Findbugs is a very useful plugin for finding low-level, unexpected problems, such as possible empty references, string. format formatting problems, and more. 7. Team communication Things will come when there are many people, and there are bound to be some weird problems, which need to be solved together. The underlying framework of the problem, to quickly repair optimization. Process issues, optimize process specification and inform team. It would be nice if there were a wiki or a forum or something to keep track of all the holes people walk in. Hold regular meetings to synchronize progress and problems.

Four. The test code is finished, need to have a strong test team to test the function. Our project is interface, external output JSON data, if there is no automatic comparison tool, all rely on the naked eye really crazy. Missing fields, case problems, formatting problems, all kinds of things are going to leak out, and it’s time to refine the specification. 1. Automated testing this depends on the test strength, I do not quite understand, there is a test bull is how important. 2. Interface document development in the interface to do the time to update the document, modify the code to update the document. Of course, writing documentation is boring. Annotations in Java can do this and automatically generate online documentation. 3. How to evaluate whether the interfaces of pressure test and concurrent test can support the business depends on the results of pressure test. Is not up to standard? Optimization!

Five. Online this time to think about how to standardize the release process, if the company has a team to help you do automatic integrated release is great, if not, you can only masturbate. What Jenkins? Pack up the script and do it yourself. What, the code server and the live server are not in the same room? SVN, Git will take care of it for you. Tomcat also has the ability to upload war packages. 1. Application servers Evaluate the number of servers based on traffic volume. Do you want to split the interface, such as ABC interface only access A server, DEF interface only access B server, nginx access layer up. 2. Release release process and release system. Do YOU need grayscale publishing? Whether to roll back quickly. Configuration management system up. One of the most important jobs of a programmer is to watch the monitors. Call volume, peak call volume, success rate, failure rate, timeout rate, average time, etc. It is best to view the code returned by the interface call online to quickly locate the problem. In addition to monitoring app calls to your service, there’s also monitoring your calls to other people’s services. One is to discover your own problems, the other is to discover the problems of others, quarrel and quarrel, to show evidence. Failure rate, timeout rate, and average time taken are all necessary kpIs for dad programmers. It would be better to have CPU, memory, network card usage, etc. Furthermore, it would be even better if there were JVM monitoring! We’ve got the cameras, we’ve got to call 911, text messages, emails, you know what I mean! One of the most important jobs of a programmer is even more important than monitoring. It is important to look at the error log when monitoring is delayed and problems may not be detected in time. Logs are used to determine whether the system is running properly. Error logs can help you find problems, even before users find them and fix them. Dad programmers also need to see if the log is too much, too little, in the wrong place, important business log. This is a long-term process, gradually adjusted according to the situation. Observe the online server logs, is the top priority of dad, before the user found the problem, before the customer service event to solve the problem, escort, it is not easy ah! So, hot how many servers, you’d better have a log receiving system, online view screening system. 5. Ensure the stability of nginx access layer, use Nginx in front of Tomcat as access layer, use Nginx to do distribution, do grouping of servers, peripheral services are suspended, can not affect the core business. For example, if you have an a.site.com site to change, the old a.site.com domain name cannot be used, and the new version of the a.site.com domain name must be used on other servers, then the function of nginx access layer is shown, the new version of the page to the new site. All the others back to the old station. Done.

If one of them fails, it could be a disaster for you. How do you avoid this situation? This is also what I am doing recently. I searched around and all of them are talking about Netflix’s Hystrix. This should be a relatively mature solution. Circuit breakers and downgrades can only ensure that microservices don’t start a fire, but they can’t guarantee that the front end will fail, so it’s better for the front end to work together and provide some soft, well-experienced error prompts.

In the end, being a dad is more than that, and being a parent is more than you think. Discuss requirements with the product, customer service incident investigation, discuss technical solutions with colleagues, communicate with the test to fix bugs, and report to the leader. What? Can’t open the app again? What? Machine room malfunction? What? Someone is swiping the interface? No end…

——————————————————

Network card is full when the first encounter network card is full, feel very magical, there is A cattle A and cattle C between the feeling. Over time, it’s nothing new for network cards to be full. During the pressure test, the QPS could not get up. It was later found that the network card of the pressure machine was full. The service crashed, the cache server card was full, and the single key was too large. Conclusion: the network card is full of things to consider, especially when you transfer things back and forth both major and high usage. The solution is that the single key value should not be too large, and no matter what the cache, with the increase of value size, performance is sharply reduced, so it can be dismantled, now is distributed cache, the more keys, each server is more average, the increase of key has little impact on performance.

Tomcat restarts automatically at peak times. I can’t find the reason. Dad has a challenge. As said before, the child is sick, you have some medicine to eat well, then ask the doctor to prescribe, ask others to cure is also rehabilitation ah. Later, I did dump and TCP monitoring when Tomcat was restarted. Later, IT was found that Tomcat had too much time wait during the restart, and it was inferred that there was a performance problem in the invocation of a certain service. There was too much backlog, and when it accumulated to a certain extent, it exploded. Increase the number of RPC calls for a service. Another point is the use of synchronized keywords to be careful, careful performance problems, will block.

3. The monitoring curve suddenly disappeared and dropped to 0, which made me scared. I quickly checked the log and found that there was an error when reporting monitoring, and the thread reporting was suspended. Change bai, on report wrong wrong, can’t make shock!

—————————————————————–

Conclusion: The above are some of my experience, may be nothing special for you, I can only say that I am uneducated, unable to keep up with the pace of technological development. If you have better, please do not hesitate to give advice, we grow together! All of these things are huge for small companies, small teams, or projects that start from scratch. Surveillance systems, logging systems, operations, distribution, there are holes for you to tread. Our current RPC call scheme, cache, MQ are all third party, although there is technical support, but still a lot of holes. Pits are everywhere, all we have to do is step on the pit not to fall!