preface
Front-end development has been a hot topic in recent years, and more and more practitioners are involved. In the past, the front end was limited to restoring design documents and doing web interaction. Today, the front end has changed so quickly that there are many niches, such as visualization, small programs, audio and video, and so on. In actual development, the front end is very dependent on the cooperation of other positions, such as UI, back-end, product, testing, etc., design draft, background data, product interaction, etc., can not be done by themselves. Many of the front ends have also realized this problem, found that focusing only on the front end is not enough, and have moved from the front end to the full stack. But if you want to build the server environment and database by yourself, you still need to learn a lot of back-end and operation knowledge. Such learning cost is undoubtedly very high. The smart front-end gurus came up with a way to make the front-end a full stack faster: Serverless. Using Serverless cloud development to replace the traditional development, can make the development efficiency greatly improved, front-end engineers only need to focus on their own business, do not particularly care about the server environment, database and other problems, a few simple commands, can easily let the business on the cloud.
Last weekend, I participated in the sixth session of the front-end early chat conference, and learned the valuable experience of the development of Tencent and Alibaba big man Serverless. I would like to share this experience with friends who are nuggets of gold.
Serverless cloud development case
Let’s take shenzhen Airport as an example. This project has both Web and small programs. The application layer is deployed in the cloud and can be built quickly with Serverless framework. Cloud services are also very complete, domain name, storage, database everything. The following figure is the architecture diagram of the project. The small program side, application layer and cloud service are clear at a glance, and it will be much easier to understand.
Because small programs run in the wechat environment, and the wechat development environment is special, in the actual development process of small programs, often face user information authorization, security check and other links, the traditional manual writing background configuration is very tedious. With the off-the-shelf services of cloud development, online deployment and log detection are very convenient, and front-end development engineers can handle the whole process of project development alone without back-end and operation and maintenance.
In addition to the Shenzhen Airport case, there are many other companies using Tencent Yunyun Development. Here are some other cases, you can search by yourself if you are interested.
What can be done with Serverless?
The preparatory work
Cloudbase, developed by Tencent Yunyun, can help developers to develop various applications easily with Serverless. It supports mainstream front-end frameworks on the market, such as multi-terminal Taro, so that based on mastering the Taro framework, you can quickly develop a small program based on cloud development platform to do some specific command configuration. Take the Hacker News project as an example:
After passing the above commands, you can generate template directories and files, configure the appID of your own small program, and preview the experience in wechat developer tools.
The page alone is not enough, if a website, data content needs to be updated frequently, then content management system is essential. Cloud development recently launched CMS plug-in, without development can be configured to generate content management pages, and support multi-end adaptation, as well as system administrators, operators of user access control. With this expansion capability, it is very convenient to manage the project content in a unified manner.
Cloud database Calls
Since we have no back-end staff, we can use the cloud database developed by the cloud to achieve CURD operations on the database. The database can be created through the official @cloudbase cli, or controlled with vscode plug-in, or wechat developer tools. The database uses a non-relational database, much like MongoDB, which is hardly front-end friendly. When you do it all, you get a familiar feeling.
Realize wechat message subscription with cloud development
This is a new capability that will be officially available in early 2020. It will allow apps to actively push information to users in the form of subscriptions.
In the traditional way, the backend needs to obtain the wechat open platform API, and the small program side also needs to communicate with the wechat middleware, which also has complex cache problems. Now we have a new choice, using the way of cloud development, directly call wechat open platform API, eliminating all kinds of troubles in front end, back end and wechat open background docking, greatly reducing the cost of front and back end joint adjustment, and reducing the possibility of mistakes.
Cloud development vs. traditional development
The traditional development model is mostly a waterfall model, from requirements to design, to research and development testing, to the final deployment online, maintenance and so on. The disadvantages of this mode are obvious. Each stage is completely fixed, and the next stage can only be entered after the previous stage is completed. If there are problems in one stage, the problems will become more and more serious in the later stage, leading to the difficulty in ensuring the quality of the development project. Such shortcomings in the Internet products, will experience very obvious. Whether it is the uncertainty of the demand, or the later modification and maintenance, will bring great work pressure to the developers, and the solution to the development problem is not achieved overnight, need repeated investigation, trial and error to reach the correct conclusion.
For developers, on the one hand, they need to understand the business requirements and make products that meet them; On the other hand, we have to solve all kinds of problems encountered in development, including but not limited to code logic errors, environment configuration problems, online deployment problems, multi-platform compatibility, and strange unknown problems.
And the emergence of cloud development, can let front-end development pay more attention to their own field, pay attention to the realization of business requirements, such as database, server operation and maintenance can not care about, these cloud development has helped you do, basic can do out of the box. With the help of cloud development capabilities, in the past, the front and back end need to cooperate with the development of a week long project, perhaps a front-end can be completed within three days and released online, so that the improvement of development efficiency is unprecedented.
Here’s a good comparison of traditional and cloud development:
Is Serverless the silver bullet?
Unfortunately, the answer to this question is no. At present, both Serverless and cloud development can only solve some general business scenarios, not cover all aspects. Take the most practical example, the current company projects are all traditional development mode, have their own domain name, server, certificate, database and so on, it is really difficult to migrate all to cloud development. Moreover, for companies with strong technology research and development strength, they prefer to control the data in their own hands rather than cloud manufacturers, so many companies still do not follow Serverless, but continue to use the company’s original technology system.
However, there are still many companies that are interested in front-end technology and adopt hybrid cloud solutions, which simply means that part of the business is in the cloud and part is not in the cloud. This can do rain and dew evenly, for example, activity class H5 has a very similar timeliness, and the implementation is not complex, so it can be put on the cloud development platform. But some core businesses, such as payment systems in the financial sector, may be less suited to the cloud.
For the front-end development engineer, I think it’s necessary to learn the Serverless, it can help you quickly develop a complete project, more focus on their own domain knowledge, at the same time also can have more energy to focus on the needs of the business itself, let you in the conversation, agile development, cloud computing era of the three musketeers gradually popular, shine brilliantly.
conclusion
The above content is shared by the lecturer @Zhao Bing of Tencent in the sixth session of “Front-end Early Chat Conference”. At first, the case introduction of Tencent Cloud development based on Serverless was carried out in a small space. Later, the routine operation of Serverless cloud development was explained through actual code practice. The lecturer’s logic is very clear, and the whole thing is very smooth. Other lecturers shared very well, but I needed some time to digest the information because it was too much.
Many of the views above are based on the lecturer’s sharing and my personal experience. Please forgive me if there may be many imperfections.
Through recent meetings and daily understanding, I have seen the development trend of Serverless and its profound impact on front-end development. Here I want to share this article with you who are reading. I hope we can go on more smoothly and live as we want.
Front-end Early chat conference goal to become useful, understand, copy the technology conference, planned to be held in 2020 >= 15, jointly held by front-end early chat and nuggets, front-end early chat conference schedule dynamic, video recording /PPT/ lecture notes download, please pay attention to the “front-end early chat” public account follow up.
On May 30, held the 7th – front end how to make the front, please stamp: www.huodongxing.com/go/tl7, posters and lecturer itinerary is as follows:
Held on May 31, the eighth – new strategy, front-end job-hopping registration please stamp: www.huodongxing.com/event/25439… , posters and lecturers’ itineraries are as follows: