Home Blog Talks

FaasJS vs MVC

2019-10-24

Today is 10.24. First of all, I wish you all a happy holiday, no bugs, and get off work early.

Today I want to tell you about the design concept behind FaasJS:

**Use Function + Folder to efficiently build and iterate complex business applications. **

As a developer, you need to face two kinds of complexity: business complexity and scale complexity.

The best way to solve complexity is to split it.

The approach of the MVC framework is to split a single application into multiple single applications, and then provide services through a container cluster, thereby splitting and decoupling business and scale, and improving throughput and stability.

But this approach has three disadvantages:

  1. Planning the split of a single application requires a deep understanding of the business architecture and technical architecture, and the workload and difficulty of the work are not low;
  2. The high cohesion characteristics of a single application will lead to the need to split it again as the business grows;
  3. As the number of applications increases, the dependencies required by the development environment and test environment become more complex, and deployment and operation and maintenance become more and more difficult.

Simply put, solving complexity problems by splitting applications actually transfers complexity to the operation and maintenance level, and will lead to an exponential increase in complexity at the operation and maintenance level.

So how does FaasJS reduce this exponential increase in complexity?

First of all, at the operation and maintenance level, the deployment object of FaasJS is a FaaS cluster, and its basic unit is a function, which will bring the following benefits:

Next, at the development level, FaasJS mainly uses the following methods to reduce complexity:

  1. For business process programming, use functions instead of classes;
  2. Intuitively isolate business areas in the form of folders;
  3. Split the function into units so that the complexity can grow in a smoother linear manner.

In order to achieve high cohesion, MVC uses a layered architecture and object-oriented programming. However, as there are more and more levels, the inheritance relationship of classes becomes more and more complex, and the complexity increases exponentially.

FaasJS adopts functional programming for business processes and completely controls each business process into a predictable input/output function to control the complexity of development and testing.

At the same time, using folders to divide cloud functions not only makes the overall architecture more intuitive, but also makes splitting and reconstruction more flexible.

In FaasJS, each folder can be configured independently, subfolders can inherit the configuration of the parent folder, and the configuration in the cloud function code can override the folder configuration.

This provides intuitive inheritance and isolation at the configuration level, and as cloud functions are deployed online, the configuration file will be locked in the state at the time of deployment without worrying about being tampered with.

To sum up, FaasJS is based on Serverless technology and uses Function + Folder to greatly simplify code iteration and reconstruction costs, allowing the business to be updated quickly, so F also represents Fast (although at the performance level, in the context of Serverless, Node The performance advantages of .js are relatively less prominent).

Back to all posts