Question on how to use this framework #1143
Replies: 12 comments
-
Hi Dat,
Cheers! |
Beta Was this translation helpful? Give feedback.
-
![capture](https://user-images.githubusercontent.com/6136034/41508746-07ed61ac-720f-11e8-92ce-2d64ccd6fff9.PNG)
Great questions I think we all go through. My thoughts:
1. Both on the backend and front end I've struggled with scaffolding questions.
My conclusion after many projects is that while some folder organization is useful, a folder-per-service is useless for small projects, amazing for medium project, and painful for large projects.
For large projects, better to have lighter, broader folders for functional areas rather than microservices and use good naming conventions, e.g. `someService.microservice.ts` for the service function, `someService.moleculer.ts` for the configuration, `someService.spec.ts` for the tests.
For me a small microservice platform is probably 10-50 microservices, medium is 50 to hundreds, and large is over hundreds and up.
Microservices should be small and implement no less or no more than the granular story (message) they are there to satisfy, so that usually means lots.
2. I'd recommend thinking about it as having a REST API gateway whose endpoints perform authentication and authorization, then delegate to reuseable microservices.
I've attached a conceptual diagram I'm using in my journey in my team.
If you have fine grained authorization before every microservice make sure its actually useful.
3. No opinion on NATS except to make sure that it easily fits within your OS brand/version.
…On Sat, Jun 16, 2018 at 3:34 AM datnguyen293 ***@***.***> wrote:
Firstly I love the idea of the framework and started writing some
services. I'm now going to use this framework for a bigger project which
has more than 10 services, so I have couple questions:
1. Should I maintain only one project source based and write all
services under the "/services/" folder - or each service should have its
own project structure which generated by moleculer-cli?
2. REST requests to almost services need to be checked for
authorization so I'm thinking of writing an auth library which required by
all services. The library provide the most important function
"isAuthorized()" function. Where should I put the library? Should it be a
github package and included in packages.json?
3. I don't have much experience with NATS server so do you have any
suggestions on how to maintain this service stable? Can it be multiple
instances behind a load balancer?
Thank you very much,
Dat
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#303>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF2g4mHstohReZ5Ic9ghpeY4tAc1Al7Eks5t9MMugaJpZM4UqaI0>
.
|
Beta Was this translation helpful? Give feedback.
-
@FranzZemen the attachment is missing. |
Beta Was this translation helpful? Give feedback.
-
Thank you all for your good comments and I more understand what need to do. A comment to my question is when I mean 10 services which means 10 different components and each of it has many services/api in there. Thanks, |
Beta Was this translation helpful? Give feedback.
-
I believe, managing 10 services under one project is not good practice in terms of scaling. What do you think, guys? |
Beta Was this translation helpful? Give feedback.
-
@ghqppio as far as I understand, @icebob suggested to manage all services under one project but in deployment you can start only one/or fews services under the project. That's no conflicts with using docker/kubernetes at all. |
Beta Was this translation helpful? Give feedback.
-
Yes, that you put all services in a project, you can still run them in separate containers. Example: https://github.com/moleculerjs/moleculer-examples/blob/master/conduit/docker-compose.yml |
Beta Was this translation helpful? Give feedback.
-
Hello, I intended to make a similar thread, I'm glad it already exists. We are validating the moleculer for use, and one of the doubts that came up was: In production, it is better to use the moleculer-runner and point out which services are going to be started (in cluster mode for example). Or use a broker.start somewhere with the services you want. Can I protect others services running moleculer-runner if one service crash? Any tips to create a restart behavior like PM2? |
Beta Was this translation helpful? Give feedback.
-
@ghqppio well, you probably can build different docker images from the common codebase for each separate service. but yeah, it's not a really good solution though. in my own case, it was much easier and better to create 10 repositories with about 10 lines of copy-pasted code each, than create 1 repo, but handle that intelligent build process but have no copy pasted code |
Beta Was this translation helpful? Give feedback.
-
my choice is to use ci tools to shink source code for one service. |
Beta Was this translation helpful? Give feedback.
-
@soluty The script sounds interesting. Would you mind sharing it via gist or similar? I think it would have the potential to become part of the |
Beta Was this translation helpful? Give feedback.
-
@katsanva My team does the same thing; we have several repositories and we have a template repository (fork of the official template customized for our needs and on our enterprise GitHub) which we used to generate new services with all of our healthcheck and CI scripts, common Dockerfiles, etc. Technically you could argue that splitting them into separate repos is most in line with the entire idea of microservices in the first place; separation of concerns, data boundaries, etc. Furthermore, in many situations - not my teams, at least not yet - you have a different team managing one or more microservices each. I feel like this sort of "encapsulation" extended to the repository level makes a lot of sense. All of that being said, one of my favorite things about Moleculer is that you have options. |
Beta Was this translation helpful? Give feedback.
-
Firstly I love the idea of the framework and started writing some services. I'm now going to use this framework for a bigger project which has more than 10 services, so I have couple questions:
Thank you very much,
Dat
Beta Was this translation helpful? Give feedback.
All reactions