Sadiqul
Sadiqul

Reputation: 145

Is it possible to build a project using different languages via microservice?

Is it possible to build a project using different languages via microservice? Like, I want to build a hotel management system, can I use both asp.net core and nodejs for different modules. Suppose I want to get my data using nodejs and post data using .net core. TIA

Upvotes: 2

Views: 4442

Answers (4)

Reza Alizade
Reza Alizade

Reputation: 318

Well I think Docker is what you're looking for, where you can create a container for each microservice that is totally independent of others and they can communicate to each other through the network and/or files and finally, you can build all of them in the desired system with one command using Docker Compose.

Upvotes: 2

xargs
xargs

Reputation: 3079

Yes it is possible to use different languages for different micro-services. For example you can write micro-service-A in C#(.NET Core), micro-service-B in Java, micro-service-C in NodeJS and so on(you can chose from lot of languages here). But usually this is not recommended. At least not if you do not have good reasons for it.

Benefit of Micro-Service Architecture

Indeed this is one of the benefits of micro-services to be able to use different languages, technologies, libraries, databases and other components for each micro-service. But you should be careful to not overdo it and to do it only when needed. In the reality companies and their development teams stick to 1 or 2 tech stacks and develop all of their services with it.

Reasoning for picking different languages and technologies

Here are a couple of things you should consider before doing that:

  • Developers skills. Review your developers skill set and know-how in one of the tech stacks/languages. If most of your developers are skilled in .NET chose .NET as the cost of switching to another Stack/Language will take time and learning effort.
  • Business requirements and domain. Consider reviewing the languages strong and weak sides before start using them. For example probably you want to avoid NodeJs if you have micro-services which have a lot of CPU intensive work/load. Probably in this case .NET Core or Golang would be a better option. Most of the main Tech Stacks will cover the standard requirements of web development but reviewing and analyzing in advance is always good.
  • Databases. You are not only flexible with programming languages but also databases. Pick a database which suits best for the particular micro-service domain or use case. For example usually for most micro-services with standard CRUD type operations you can take some Relational Database like Postgresql or MySql. On the other hand if you have a specialized case like a micro-service which has some full text search requirements ElasticSearch would be a good option. This really depends on your needs.
  • To many technologies. To many programming languages, technologies, frameworks and database technologies also mean different kind of maintenance problems. Updating libraries, writing Repository classes for multiple database technologies takes time and effort.
  • Historical reasons. Some companies have some legacy system which was developed with some older technology like VB6 or similar. For example they connect to it to extract some data. If they decide to migrate some parts of the system(or the whole system) to micro-services they pick a new tech stack or multiple tech stacks(newer technologies will attract developers ;) ). And for some bridging time they have a system with multiple stacks/languages until migrate all of it to the newer one.
  • Consider shared libraries(packages like npm, nuget, etc..). If you have most of you micro-service written in the same language then you can create and reuse common code. This includes things like cross cutting concerns like: Database access code(Repository, Unit Of Work, ORM), Queue interaction code, Testing infrastructure(Unit and Integration test infrastructure/setup code), Logging and other common code. If you use a different language for different micro-services then you will not be able to share these kind of code. Writing and maintaining this in multiple languages can cost a lot of time.
  • Front-end. Similar applies for Front-end. Technically if you have your front-end modularized or splitted in micro-front-ends you can use different technologies(libraries and frameworks). Usually as with backend micro-service you pick one library like for example React and stick with it unless you have strong reasons to use and/or combine it with something else.

Conclusion

My advice would be to pick one tech stack/language and develop all or almost all you micro-service in that language. Similar goes for database, cache and FE framework/library. Only chose a different technology/language if you have a strong reason to do and you main language/stack is not performing or fitting well. Like I explained with the Elastic Search example above. The decision which language depends on a lot of different factors.

Upvotes: 4

xs2tarunkukreja
xs2tarunkukreja

Reputation: 462

Yes, you can choose different set of languages/tools/technologies for different set of Microservices. But better option is to choose one language with which team is fully comfortable. If you choose another language then you should have specific reason. For e.g., in one of my project, most of the services were written in Node JS. We wrote one service in Go Language as we need performance.

Upvotes: 7

Jukka Paulin
Jukka Paulin

Reputation: 11

Yes. You need then some form of interprocess communication (IPC). Each language lives in its own process, regardless of what the operating system flavor is, or what language you have used. Often processes practically communicate via APIs. There are also other ways to arrange IPC, via database, memory (RAM), signals, or even plain files (which are on some shared medium).

Upvotes: 0

Related Questions