introduction

State-owned, head of idle fish architecture team. Archsummit 2019, which ended on July 13th, shared the explorations and practices of idle fish in Flutter&FaaS integration project in the past year.

Challenges of traditional Native+Web+ server-side hybrid development

With the development of wireless, IoT and 5G, mobile r&d is becoming more and more multi-terminal. The traditional development mode based on Native+Web+ server is inefficient in research and development, and obviously cannot meet the needs of development.

We want to explore the efficient development architecture of an independent APP of xianyu’s size. The main idea is to solve multi-terminal problems around Flutter, and make Flutter and FaaS and other non-service capacity open, forming cloud integration research and development capability, to support the development needs of one cloud and multi-terminal. In some scenes have achieved the effect, hope to share the process of thinking and communicate with everyone.



Comparison and selection of cross-ended schemes, Flutter and RN

The idle fish chose Flutter mainly for high performance reasons. Flutter performance is mainly due to two reasons:

  1. Dart’s AOT compilation capabilities.
  2. Self-built rendering engine, no need to convert to Native controls, avoid thread jumping and other issues.



More comparisons:



There is no silver bullet solution. Flutter and RN each have their merits. There are many factors in how to choose. The key is how to make a choice. For example:

  • Is the current team member based on front-end JS stack or Native? If JS is dominant, it’s more comfortable to write RN. If Android or iOS is dominant, writing Flutter will be more comfortable because the Flutter development tools and experience are more similar to Native.
  • Which is more important, dynamics or the performance of complex interactions? While dynamic RN is important, the performance experience of Flutter is important and will not be disappointed. Although there are some dynamic solutions to Flutter, such as JS transfer to the Flutter engine, Dart CodePush, and component-based server assembly, none of these dynamic solutions are as good as RN’s solution from the JS layer.
  • Is multi-terminal layout such as IoT required? The Flutter has a layout and better performance in embedded design.

Dart is the first language of choice for the FaaS layer

The opening of the cloud technology stack is a good solution to reduce synergy. Previous front-end +Node.js solutions should be familiar, but cloud side Dart is naturally the first choice if the end uses Flutter.



The nature of FaaS is to run in the cloud. Is Dart suitable for the cloud /Server?

Dart language predates Flutter. Dart was originally designed for use on the Web and Server. Dart has some server-side language characteristics:

  • Strongly typed and predictable
  • GC
  • Asynchrony and concurrency
  • High performance JIT
  • Profiler

Idle Fish first tries to use Dart as a normal Server instead of a traditional JavaServer, and then embed the Dart container in the FaaS container. Establishing the Dart Server capability is the first step and the bulk of the effort.

Construction ideas of Xianyu in DartServer:

 

Development period:

  • Inspired by the HotReload of Flutter, HotReload was ported to the Server side.
  • Using the Isolate, each developer in the development environment was assigned one Isolate to resolve previous environmental conflicts.

Runtime:

  • Dart itself is a single-threaded asynchronous model, and concurrency needs to be supported with Isolate.
  • Dart uses the Zone feature to Trace invocation links and record Trace logs.
  • Using the C++ Extension capabilities that Dart supports, you can access C++ -enabled middleware packages in Dart. In addition, the Server Mesh is an important idea to decouple service invocations between heterogeneous languages.

Deeper thoughts on integration

The above content realizes the unification of technology stack of Flutter&Dart FaaS, but the unification of technology stack alone is far from enough. The end and cloud students still cannot really complement and integrate, because there are more in-depth issues to be considered:

  • How to maximize the integrated business closed loop dividend? Integration not only improves efficiency, but also enables a student to Cover a cloud to the end of the business, so that the business closed loop.
  • How to remove cloud technology barriers? Once the technology stack is completed, the end staff still cannot write about cloud. The reason is that they do not understand the thinking mode of cloud, so they need to remove the technical barrier of cloud.
  • How to reduce the total amount of work (1+1<2)? If the workload is put on one person after integration, it does not make much sense. The total workload under integration needs to be reduced.
  • How to promote the remodeling of production relations? Relations of production need to adapt to the new productive forces.



Facing these problems, Xianyu’s solution is as follows:

  • Business closed loop brings better growth space for business development students, who can think about business in a complete and focused way. This is the core human motivation.
  • Business closed loop is the direction of business process precipitation
  • In the past, cloud and terminal architectures were separated. After integration, there is more space for the architecture to sink, thus bringing the possibility of 1+1<2 total workload
  • Field sinking and tool support ensure integration

Effect of case

Case ONE, the embodiment of integration in resource balance. In a recent project, cloud integration reduced the project time from 2 months by 20 days.



Case two, the embodiment of integration in business closed loop. A development student in charge of growth focuses on growing the business, delivering the right content to the right people in the right circumstances in order to grow and activate users. In the integrated mode, the cloud and terminal aspects can be unified, and service r&d is no longer limited by the cloud and terminal.



summary

Integration is the direction of building an efficient RESEARCH and development framework. Not all scenarios require integrated development. However, integrated Flutter, FaaS and other technical components can be used independently to improve efficiency and are compatible with the existing development model. Construction from the idea of integration can make the overall architecture system more consistent, but also have the opportunity to do the integration of architecture precipitation. In the future, Xianyu hopes to make more attempts and in-depth exploration in integration, including integration tools, integrated business platform, data and intelligence.


Author: Idle fish Technology – state-owned

The original link

This article is the original content of the cloud habitat community, shall not be reproduced without permission.