TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Building Microservices the Lean Way, part 2

104 pointsby tmwatson100about 10 years ago

7 comments

latchabout 10 years ago
FWIW, I&#x27;ve found that building a robust and deep &quot;API Gateway&quot; is the key to making SOA&#x2F;Microservices work. Otherwise, you end up with duplication and latency.<p>Routing and authentication are obvious candidates. It&#x27;s also a good place to track stats and tag each request with a unique ID so you can trace it as it flows through your services.<p>By &quot;deep&quot;, I mean that it should be application-aware. Caching is a good example. For many applications, url + querystring results in too many permutations. If the cache is aware, it can often use more meaningful keys. Additionally, events in the underlying services can be used to cache purge, which can result in a wicked cache hit ratio.<p>A more complex example has to do with duplication. Say you&#x27;re building an ecomm platform. You have a service for search, and one for recommendations and one for the main catalog. They all need to return the same representation of a &quot;product&quot;. Do you duplicate the logic? Do you tie them together and pay the latency and reliability price? No. Have them all just return IDS, and let the API Gateway hydrate the actual results. It&#x27;s a form of API-aware server-side include and it works well.
评论 #9118798 未加载
评论 #9118732 未加载
评论 #9118767 未加载
评论 #9118440 未加载
AndrewHamptonabout 10 years ago
So here&#x27;s a question we&#x27;ve been talking about at my office. When developing a micro-service on your development machine, do you need to run the whole stack or just the service you&#x27;re working on?<p>For example, let&#x27;s I am working on service A, which depends on services B and C. Do I need to run all 3 apps and their data stores locally?<p>We currently will typically point A to the staging B and C. However, we have some long running jobs that A will initiate on B and B needs to post back to A when it&#x27;s finished. This doesn&#x27;t work when pointing to staging B.
评论 #9120369 未加载
评论 #9118768 未加载
评论 #9118817 未加载
评论 #9118945 未加载
评论 #9119208 未加载
评论 #9119804 未加载
akbar501about 10 years ago
Questions for Tom:<p>1.) How are you handling auth? Are you using a home grown solution or using OpenID Connect + OAuth 2.0?<p>2.) Is the JWT behind the firewall using a pre-shared key?<p>3.) What does the public token look like and how does the API Gateway perform auth? Does the token passed into the API Gateway contain only a user id? And does the API Gateway have to perform a database query to populate the full user object?<p>side note: Thanks for writing the article.
anton_gogolevabout 10 years ago
Is it just me or this is a tech homeopathy article?
评论 #9118390 未加载
评论 #9120427 未加载
codewithcheeseabout 10 years ago
Hi Tom, I too have a django monolith. But, I hesitate to go down the microservices route, since I reuse alot of classes in what would become different services. Can you comment on how your class structure has changed, and how you have maximized (or not) code reuse?
评论 #9118427 未加载
评论 #9118534 未加载
hannes2000about 10 years ago
&gt; Finally, how do we deal with our monolith? We decided to treat it as if it was a (very large) microservice.<p>Judging from your team size (3 engineers on the team page), this is probably still a very normal-sized microservice :)
gabrtvabout 10 years ago
&gt; The services are considered to be in a trusted network and are accessed by a private token passed in the ‘Authorization&#x27; header plus the user id of the requester in an ‘X-USER’ header.<p>This reads like the user ID is exposed in a header without any sort of encryption.
评论 #9119130 未加载