Typescript and Microservice Don’t Mix
At first i thought that’s normal and typescript won’t affect microservice development cause i don’t have much experience in typescript and loopback framework but on the other hand i found that the company implement Microservice architecture the wrong way.
As we know CAP Theorem which say in summery that you have 3 ways to build functional system. Build it (Consistent Available), (Partitioned Available) or (Partitioned Consistent).
Consistency (all nodes see the same data at the same time) • Availability (a guarantee that every request receives a response about whether it was successful or failed) • Partition Tolerance (the system continues to operate despite arbitrary message loss or failure of a part of the system).
Availability is the main recipe in the equation of microservice. If you build it (Consistent Partitioned) you gonna lose Availability which will make your microservice maintenance process a living hell and (Consistent Available) means your system is monolithic and not partitioning exist.
So on joining i found them not implementing any of the CAP Theorem models for microservice. No local transactions, no distributed transactions (SAGA), No API gateway, No discovery, No redundancy, nothing just REST API calls and huge mesh of services calling each other and front-end can call them directly without gateway.
A lot of people call that a Microservice, and i call it bullshit.
So i decided to reform the system and make 2 architectural plans
- Short-Term: in which i will gonna fix the current services with what can be done to postpone problem I anticipate.
- Long-Term: in which i will implement new architecture for Microservice which adopt (Partitioned Available) model.
As i said before they were using a Typescript for the microservices, so i checked 2 frameworks [Loopback, NestJs] to see if they can support Microservice architecture using (Partitioned Available) model. and i discovered in nutshell that these frameworks are good for (Consistent Available) model only. You can’t build a true microservice project with them.
So i decided to build my framework which will achieve my goal which is (Partitioned Available) model.
After one month of investing in Typescript i discovered a big problem which stopped me, It’s Reflection.
So i discovered that’s why Loopback & NestJs have limitations in the domain of microservice but is that mean typescript is bad, Ofcourse NO.
Typescript is good for Mono-Systems but not for True Micro-Systems due to lack of Advanced Reflection.
Language decision is important when you try to build a Microservice system so always choose right (C++, C#, Java).