Should I Build a Monolith or Microservices?

  Рет қаралды 8,291

IAmTimCorey

2 ай бұрын

If I am building an app, should I design it as a monolith or should I use microservices? Should I convert my current monolith to microservices? What are the things I should think about before making a decision? These are the questions we will cover in this episode of Dev Questions.
Website: www.iamtimcorey.com/
Ask Your Question: suggestions.iamtimcorey.com/
Sign Up to Get More Great Developer Content in Your Inbox: signup.iamtimcorey.com/

Пікірлер: 95
@alexandrualimpie3171
@alexandrualimpie3171 2 ай бұрын
Excellent information, and btw keep providing materials about architecture because not only juniors are watching your videos ! Great video!
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Thanks for sharing!
@johno8760
@johno8760 2 ай бұрын
It's still great knowledge for a Junior dev though! I've always wondered what the difference was between the two in a deeper sense and what justifies each one
@anonym6891
@anonym6891 2 ай бұрын
I agree, would love to see more videos about useful architecture tips :)
@cirdec115
@cirdec115 2 ай бұрын
At this point I think we need to change the "Monolith" name... Popular opinions reference Monolith like it was a "disease" and the solution is the Microservices... But in fact if you are not able to build a clean Monolith you'll end up having a lot of fun with Micro Services 😉
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
True, but my guess is that it wouldn't be any different if we changed the name. That would just be more fodder for the click bait crowd.
@meytechchannel3087
@meytechchannel3087 2 ай бұрын
Around 85% .NET job descriptions are asking for experience in Microservices, but most of the time they can't really tell the actual reason why. The answer is always scalability and nothing more in detail.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Yep, and they probably don't understand the scalability aspect. It is like putting a spoiler on a Toyota Corolla.
@andergarcia1115
@andergarcia1115 2 ай бұрын
Starting the day by learning from you is a pleasure. Thanks, Master.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You are welcome.
@torrvic1156
@torrvic1156 2 ай бұрын
Thank you so much for sharing your profound knowledge with us Tim! It is so much fuss about micro-services that it makes it really confusing to understand why everybody are doing it with some vague reasoning.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You are welcome.
@user-bb3um9kr5i
@user-bb3um9kr5i 2 ай бұрын
A good video as always. also good timing overlap with the modular monolith episode on rocks. More Info always better and makes it sink in more for me8).
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Thanks.
@faisalalhoqani6151
@faisalalhoqani6151 2 ай бұрын
Thank you dear Tim for making it so clear, keep it up dear, and thank you again for your valuable quality content.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You are welcome.
2 ай бұрын
Thanks, Tim. Good one! 👍
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You are welcome.
@iamkgraman
@iamkgraman 2 ай бұрын
Thank you for your valuable information🎉🎉🎉
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You are welcome.
@KurniawanJatmika
@KurniawanJatmika 2 ай бұрын
I'm becoming a tech lead next month in a new employment and this video is a great consideration material for my new role and works to be done there. Coincidentally in my last employment, I stick to the principle that Tim explained in this video, and yes, not everything needed to be ported to the microservices.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Thanks for sharing!
@MrKaraMilli
@MrKaraMilli 2 ай бұрын
Thanks for the video! Can you please suggest or make once some separate video about best ways on how to test monolith, especially layer between unit and e2e ui tests? Or only monolith way is to use unit tests?
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
@EliasLoveL
@EliasLoveL 2 ай бұрын
Thank you Tim Do you have any series or introduction video about what is modular monolith with the best practices for that? or should I suggest that on suggestion site?
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
I would suggest it on the suggestion site. I don't have one yet, but that is an interesting topic.
@ulrich-tonmoy
@ulrich-tonmoy 2 ай бұрын
Microservices are great for company like meta as they need to continuously add/test new features but for most other cases monolith is still better
@MrLordgiblet
@MrLordgiblet 2 ай бұрын
Totally agree, micro services end up in a mess of dependencies to manage
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Agreed.
@abhishekjadhav9289
@abhishekjadhav9289 2 ай бұрын
Thank you Tim for priceless information and clearing the air. I was very overwhelmed with the term Microservices being mandatory requirement in many job requirements. Just a question, as you mentioned write loosely coupled monolith applications. Does having many separate layers or projects in one solution with proper DI and unitOfWork implemented is considered loosely coupled as well ?
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
It depends on the project. You can have a loosely coupled application with just one project (or maybe two since I really don't like the UI tied to the business logic/data access).
@Pushkerkec
@Pushkerkec 2 ай бұрын
The whole video talked exactly same word what I am advocating from a long time. Thanks putting in a video so that I can share
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You are welcome.
@sohaibalvi4410
@sohaibalvi4410 2 ай бұрын
Tim is always a great mentor.
@IAmTimCorey
@IAmTimCorey Ай бұрын
Thank you!
@lEduS89
@lEduS89 Ай бұрын
Thanks
@IAmTimCorey
@IAmTimCorey Ай бұрын
Thank you!
@jonclark25
@jonclark25 2 ай бұрын
We've just successfully deployed a microservices based Api in AWS. We liked the idea it was highly configurable on a very modular level, and that cost is pay-per-use only, also deployments are naturally a breeze which is an added bonus without setting up a blue/green mechanism manually. Maybe it's not what you would term as the justified solution for it but it's worked out great for us for what is not a massive Api but handles a very large number of requests every day. Modular monolith is something I've been considering for a few new things lately though.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You can definitely make it work, and if it works for you that's great. It probably isn't necessary, but not everything we do is.
@Rusty254
@Rusty254 2 ай бұрын
I decided to go with monolith for my latest project and I've been stressing that I should've gone with micro services. All the other devs at the company where I work have been pushing them even though we're definitely not a Google sized company. Thanks for this video, it definitely calmed my nerves.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
I am glad it was helpful.
@ahmadbinali4668
@ahmadbinali4668 2 ай бұрын
I press the like button before watching, thanks , Master
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You are welcome.
@MohamedOmar-zw2bq
@MohamedOmar-zw2bq 2 ай бұрын
You really just touch the point that I am concerned about all the time, WHY we need Microservices and What is the scale for Microservices need, but here there is a question, what are the criteria used to choose upon ?
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
When to choose microservices is going to be situation-specific, but here's a basic criteria: Don't choose microservices unless you have a scalability need that you cannot solve in any other way. For example, if you are trying to process 500,000 requests per second, you might be ready to consider microservices (but only if scaling out isn't good enough for your needs).
@isaacpalacios8921
@isaacpalacios8921 2 ай бұрын
I have seen a bunch of people speaking about and doing microservices courses, looks like this a trending topic I haven't too much about Monolithic Architecture, how can learn more about Monolithic book, courses o KZbin channel recommendation?
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
I have three courses on here about building monolithic applications: Tournament Tracker, TimCo Retail Manager, and Suggestion Site. All three are playlists on this channel.
@CyberTurd
@CyberTurd 2 ай бұрын
I think you touch on some really good points here, especially where beginners are concerned. Scale your work to the business you're working for. Any developers role is to essentially hit business goals at the end of the day - how you do is largely irrelevant to everyone but yourself. (managers and owners certainly (for the most part) have no interest) We have a monolith in our SME business (50 employees) and its fine, in fact the greatest bottleneck of the system is born from development knowledge gaps but thats OK too. No-one is an instant expert from the start and by the time you've become an proficient in something, there's a new breed of technology replacing it - its never ending. Stick with something, run with it but crucially, *make it work for the business*.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Thanks for sharing!
@clueelf
@clueelf 2 ай бұрын
monolithic is fine. Good for small, medium and large apps who don't have crazy scalability, adaptability or availability requirements mostly centered around hypercomplex application architectures (Amazon Web Services, Azure API, GCP, etc). Microservices are cool but are for big apps run by big boys (Largest streaming company in the World) on big systems (AWS, Azure, GCP) paid for by companies with all of money (Netflix, Apple, Salesforce, etc). The question always comes down to: Is doing things the microservices way worth the additional cost and hassle? In almost every scenario I have seen it deployed, the microservice juice was not worth the squeeze. Run it on K8S and you take the horror to a whole new level.
@andremaree5972
@andremaree5972 5 сағат бұрын
When stating it is a disadvantage that a micro-services have more points of failure, this is in fact an advantage of microservices. The failure of 1 micro-service should not impact other micro-services, and therefor the failure has less impact. The separation of concerns that is brought by micro-services is a great advantage over monoliths, this is not a disadvantage of micro-services, it is a disadvantage of monoliths.
@xdiepx
@xdiepx 2 ай бұрын
Hmm could I get an opinion on a 3 tier system over a monolith. We a web application but also have the system to server mobiles. Generally I use monolith as default.
@alexandrualimpie3171
@alexandrualimpie3171 2 ай бұрын
3 tier , n tier are also monolithic systems!
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Correct, 3-tier, n-tier, etc. applications are monoliths. Think of a microservice as a very tiny 3-tier application (hopefully less than 100 lines of code, but with its own interface through database). The key is do you have dozens of these tiny, independent applications or do you have one large one (monolith)?
@dasfahrer8187
@dasfahrer8187 2 ай бұрын
We've come to the exact same conclusions in our organization (with also the same human capital issues) and are already in the process of phasing out complexity and returning to simplicity and lower technical debt.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Thanks for sharing!
@doreliosip
@doreliosip 2 ай бұрын
Hi Tim, I like what you say and I think you also have in mind the idea of using in the monolit blazor and not frontend frameworks like angular. But the guys that are indoctrinated with only microservices will scream like crazy :). Maybe soon you can make a video and advice us what aproach a dev should have when he needs to fight tech-leads and architects that are not doing the right thing. Thank you!
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
@PancoCheong
@PancoCheong 2 ай бұрын
Is it a good idea to deploy 3 tiers web app to a k8s env?
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
No, I don't think so. It isn't designed for that and you aren't getting value out of doing so.
@emyrulz
@emyrulz 2 ай бұрын
While I generally agree, It is easier to work with microservices when you build new features. If you start it right, it forces you to think harder about the architecture and you will be forced to decouple your components whereas with a Monolith, there is far greater temptation to skip this especially under high pressure to deliver.
@markharwood6794
@markharwood6794 2 ай бұрын
Where so Azure functions fit into this? By the way, 100% agree that micro-services are tough and rarely the way to go.
@TealJosh
@TealJosh 2 ай бұрын
Azure functions are cloud native serverless. It's an abstraction of all the complexities that Tim talked about with something like kubernetes. Similar to AWS lambdas, but imho far more capable. I've never had the opportunity to work on an IAC project that had azure functions in it, so I can't say how close to the best of both worlds it gets. I like azure functions. You can get some elegant all in one api solutions with it and lots of other stuff too.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Azure Functions are microservices, but they can provide and standalone solution to a standalone problem. Basically, the idea of having a monolith with a few microservices where needed (not a distributed monolith).
@IkethRacing
@IkethRacing 2 ай бұрын
Too many young programmers lean toward what they consider fun instead of functional. I get it. My early days of programming revolved around what I thought was "neat" code such as segmenting code into thousands of tiny methods/objects so that I never repeat a single line of code. In every case, none of my fun ideas lasted. I learned the hard way what not to do. Microservices is absolutely one of those ideas. It's a bad idea in almost every scenario.
@nvnYT26
@nvnYT26 2 ай бұрын
What about modular monolithic or macro services?
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
I covered modular monoliths in this video.
@andremaree5972
@andremaree5972 5 сағат бұрын
In my opinion, this portrayal of the importance and role of micro-services is not completely accurate. It is definitely not only large tech companies that need micro-services. I have seen small companies that desperately needed to change their monoliths to micro-services. When comparing monolithic to micro-services, all benefits and disadvantages should be considered, not only the few mentioned here. A company might not obviously need the benefits of micro-services right now, but things change, and micro-services future-proofs and provides more business agility. The disadvantages of micro-services listed here is also not completely accurate, by stating the complexity of implementing Kubernetes/containerization. In fact, for micro-services I would recommend Azure Durable Functions running serverlessly - this is really easy to implement, and has great cost saving and other advantages over other micro-service implementations. Then there is also Azure Container Apps, which is also good and easy to implement. Modernization is simply the breakdown of larger components into smaller micro-services, and in my opinion, all companies could benefits from this. It is the new way.
@toadman5184
@toadman5184 2 ай бұрын
Microservices is a great way for service providers and consultants to make a lot of money by encouraging needless complexity. Let the buyer beware.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
For sure.
@SagharMax
@SagharMax 2 ай бұрын
I like this opinion; Microservices is compilated as unnecessary. Thank you so much.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You are welcome.
@sirus49
@sirus49 2 ай бұрын
Just so we are clear.. When your talking about a Monolith, your not talking about the Front end project/API all in one project/deployment. Your strictly talking about the API project being a monolith correct.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
A monolith can have multiple projects. What makes it a monolith is that it is directly connected together, even if loosely. Meaning a change in one part often requires a redeployment of the whole thing. An API in the middle allows for a bit of a modular monolith, which is great. It could also be termed as two monoliths if they truly are disconnected fully from each other.
@thedude6810
@thedude6810 2 ай бұрын
Make spaghetti or make lasagna
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Now I'm hungry.
@wesleyjansen2353
@wesleyjansen2353 2 ай бұрын
monolith on itself are almost always created as a spiderweb of references between the different projects in a solution. This in my opinion makes the monolith more complex then the architecture of microservices. I still agree that microservices in total are more complex then a monolith but in my opinion mutch less chaotic complex. I love microservices due to the maintainability of the code. A solution is way smaller and easy too manage. Testing your one small service and replacing it, is made way easier. I understand clean code and all, but i barely see this in a monolith solution. So most programmers i see don't really have the skills to create a monolith in a modulair way. I see this way more often when the microservices architecture is used as they are more forced to be 'modulair'. You are talking about one man's army in big businesses. I work for 5000-300.000 busnisses and they have multible teams for this. So our experiance in how a company handles IT seem too be very different. This seems to be in my opinion the reason for our different in opinion
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
If you cannot create a monolith without creating a mess, creating a microservice architecture isn't going to make things better. You are going to take those same problems and add the additional problems of eventual consistency, sources of truth, inter-microservice communication, security issues, and more. By the way, as for my experience, I've spent over 20 years being a consultant for companies of all sizes (5 employees through Fortune 500). I've done this full-time for 10 years and part-time for the rest. I've helped set the direction for hundreds of companies over the years.
@reinhardlackner1925
@reinhardlackner1925 2 ай бұрын
hm, it depents, is the only viable answer, isn't it?
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Mostly, but a lot less so in this case. There are very few situations where microservice architectures are the better solutions (and that includes massive sites and systems).
@phillismable6303
@phillismable6303 2 ай бұрын
Always late to the party
@holger_p
@holger_p 2 ай бұрын
Obviously a microservice is not a service for DI, consisting of a view lines of code only, like trimming strings. Since I don't know what a microservice is, I cannot continue. I'm just reporting, what viewers you reach here.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
A microservice is a small, self-contained application that does one job. For instance, it might just send emails. It would have its own interface (usually a small API or a listener for a message bus) and its own database (yes, a whole database just for the one service - the database cannot be connected or part of a larger database and it cannot just be independent tables inside a larger database). The idea is that you break apart your monolithic application (one application that does all of the work) into lots of little microservices. Since they are all tiny and independent, you can deploy changes to them independently of everything else. You can also scale them differently from each other. You can also have multiple of one service running to handle higher volumes instead of just throwing more resources at one. The theory is sound and it is how very large companies like Amazon handle such high volumes of traffic so efficiently. However, it has become a popular topic among developers in general. People have implemented this system in environments that do not need this type of scale. The downsides of microservices include MUCH higher complexity, many more points of failure, and much higher costs among many others. Even worse, some people have taking the wrong lessons from microservices, or they have decided that not all of the points need to be done such as independent databases. What you get then is a distributed monolith. They say they have microservices, but they all depend on the same database, which means if you change the schema for one "microservice", you have to make changes to all of the other services and you need to redeploy all of the "microservices" together. The result is all of the downsides of monoliths with all of the downsides of microservices.
@stephendgreen1502
@stephendgreen1502 2 ай бұрын
If devs knew better how to use better modularity in their monoliths (trending term modular monoliths) they would probably realise they don’t really need to distribute their modules or turn them into microservices. The big pitfall to watch out for is lack of ACID transactions across database updates once you go full microservice. Having multiple databases all on same instance still allows ACID transactions, e.g. using MSDTS or the like. But split the databases with a microservices architecture and you typically lose this capability, with likely support-intensive consequences with data loss due to eventual consistency (in other words, a lack of consistency).
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
Working to ensure ACID with one SQL database is a breeze compared to trying to handle a similar principle (can't really be ACID across services) with microservices and eventual consistency. It is nightmarishly complicated and those who think it isn't don't really understand it well enough yet.
@harrisonwell1719
@harrisonwell1719 2 ай бұрын
I think it depends, for example if you want to scale your app and you have a large user base then microservices is the way to go. That said it’s definitely more complex and way more expensive than a monolith. For most ppl monolith is the way to go.
@RaZziaN1
@RaZziaN1 2 ай бұрын
No, if you want to scale up still monolith is best choice. At the point of your scales becomes to big, important bits and pieces will need to be rewritten as external microservices, but for the time being you don't need to overengineer your app. Look at stackoverflow, it is monolith..
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
That's the trap. It sounds right. You want scalability. But you never really address what type of scale you are expecting that would warrant a microservice structure. As @RaZziaN1 pointed out, Stack Overflow is a monolithic application. They have 300 million visitors per month on an application where they are actively changing data (upvotes, comments, questions, answers, etc.) plus where they are incentivized to filter through millions of records on each visit. That's why I am skeptical of any organization that says things like "we want to scale so we are going to use microservices". Microservices use more resources by far, and are far more expensive, when you are running a site that has 100,000 visitors a day than if you just built a monolith. So you are choosing a complex, expensive solution in the thought that you might get to the point someday of being bigger than Stack Overflow. More often, the reason people choose microservices is because they don't know how to optimize code so they think that monoliths are slow. The problem is that if you build a slow monolith, you are going to build an even slower microservice setup. That means even more costs.
@harrisonwell1719
@harrisonwell1719 2 ай бұрын
It works until you have 1m simultaneous user then it'll break
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
First of all, what are you building that you anticipate 1 million simultaneous users? Second of all, Stack Overflow gets an average of 10 million visitors a day. Even they probably don't have 1 million simultaneous visitors often, but they do have them. They don't break. And they don't even have that complicated of an infrastructure. Here is a diagram of it as well as a breakdown of their numbers: stackexchange.com/performance It also looks like the numbers above were visitors per month (and might be a bit low). They serve 1.3 billion page views per month using 9 IIS servers, 4 SQL Servers (two of which are hot standby servers, and only one of which is used for Stack Overflow itself), and some caching servers. This is why I say that people who move to microservices because of scaling don't typically understand how to do scaling. The peak usage on any of the Stack Overflow systems is 20% (that's peak, not average). That means that in theory, they could serve five times the traffic without making any changes. I know I'm being a bit rough on you, and I don't mean to beat you up, but I would highly encourage you to spend more time learning how to make performant code rather than chasing after systems that are even more complicated than the systems you don't know how to tune effectively.
@harrisonwell1719
@harrisonwell1719 2 ай бұрын
I was talking generally and not specific to my use case but I think I have a valid point, for example when building something for a government entity I think microservices is the way to go. And as I mentioned before when you have a LOT of users simultaneously a Monolith is going to crash, With that said I'm not disagreeing with you about anything, Microservices are very complex and more expensive and they need a lot of resources and experienced, well rounded developers to build them well just like you mentioned in your video. Anyways great video 😃.
Follow @karina-kola please 🙏🥺
00:21
Andrey Grechka
Рет қаралды 9 МЛН
Balloon Pop Racing Is INTENSE!!!
01:00
A4
Рет қаралды 15 МЛН
Не пей газировку у мамы в машине
00:28
Даша Боровик
Рет қаралды 3 МЛН
The magical amulet of the cross! #clown #小丑 #shorts
00:54
好人小丑
Рет қаралды 19 МЛН
Follow @karina-kola please 🙏🥺
00:21
Andrey Grechka
Рет қаралды 9 МЛН