Learning Library

← Back to Library

API Gateway for Microservice E‑Commerce

Key Points

  • An API (Application Programming Interface) acts as a software intermediary that lets different applications communicate, such as when you browse Instagram or check travel prices.
  • Modern organizations are breaking down large monolithic apps into loosely‑coupled microservices, which increases the volume of API calls and creates new challenges for security, scalability, and performance.
  • An API gateway addresses these challenges by centrally managing, securing, and accelerating API traffic, improving both the end‑user experience and developer productivity.
  • In the example of a fictitious e‑commerce store (Indies Custom Threads), the gateway handles requests from web browsers, mobile apps, and third‑party integrations, routing them to specialized microservices like product info, pricing, and order management.
  • The presenter also offers a giveaway—readers who answer a final API‑gateway question in the comments can win a branded “API Gateway” T‑shirt.

Full Transcript

# API Gateway for Microservice E‑Commerce **Source:** [https://www.youtube.com/watch?v=hWRRdICvMNs](https://www.youtube.com/watch?v=hWRRdICvMNs) **Duration:** 00:10:20 ## Summary - An API (Application Programming Interface) acts as a software intermediary that lets different applications communicate, such as when you browse Instagram or check travel prices. - Modern organizations are breaking down large monolithic apps into loosely‑coupled microservices, which increases the volume of API calls and creates new challenges for security, scalability, and performance. - An API gateway addresses these challenges by centrally managing, securing, and accelerating API traffic, improving both the end‑user experience and developer productivity. - In the example of a fictitious e‑commerce store (Indies Custom Threads), the gateway handles requests from web browsers, mobile apps, and third‑party integrations, routing them to specialized microservices like product info, pricing, and order management. - The presenter also offers a giveaway—readers who answer a final API‑gateway question in the comments can win a branded “API Gateway” T‑shirt. ## Sections - [00:00:00](https://www.youtube.com/watch?v=hWRRdICvMNs&t=0s) **API Gateway Benefits for E‑Commerce** - The passage defines APIs, highlights the surge in API traffic caused by microservice architectures, and explains how an API gateway securely manages this traffic while enhancing both user and developer experiences in an online store. ## Full Transcript
0:00api is an acronym for application 0:02programming interface which is a 0:04software intermediary that allows two 0:06applications to talk to each other 0:08so every time you use an app like 0:10instagram 0:11you send us a message or check travel 0:13prices for your next vacation you're 0:14using an api 0:16apis can make or break applications and 0:19have to require additional 0:20infrastructure to secure 0:22scale and accelerate 0:24and this is the case now more than ever 0:26as organizations are modernizing their 0:28large legacy monolithic applications 0:30into smaller individual microservices 0:34these microservices are loosely coupled 0:35in order to make your apps more scalable 0:38highly available and resource efficient 0:40just to name a few 0:42however the outcome of using a 0:43microservice oriented architecture comes 0:46with many more api calls going between 0:48your clients and your microservices 0:51so how do you securely manage this 0:53influx of api traffic for distributed 0:55system 0:56well with an api gateway 0:59hell i even purchased this nifty 1:00schmedium t-shirt with an api gateway 1:03and the first lucky viewer who answers 1:05my api gateway question towards the end 1:07of this video in the comments section 1:09won their own version of this t-shirt so 1:12now let's take a deeper look into how an 1:13api gateway can both improve the user 1:15and developer experience for an online 1:17store so let's start off an example here 1:20let's say we have a fictitious 1:21e-commerce storefront 1:23indies custom threads and in this store 1:25you can order customized t-shirts kind 1:27of like my nifty api gateway t-shirt 1:29here 1:30so let's walk through the scenario right 1:32we'd have our users here 1:34and then they would make the purchase 1:35and look at the t-shirts on the website 1:37through these different clients right so 1:39you have your web application here which 1:41would be a standard web browser 1:43we'd have our mobile client as well it 1:45could be ios it could be android 1:47and then we also have a third-party api 1:50integration service right so this could 1:52be if you want to integrate your website 1:54with like say something like facebook 1:56or in our case we have a review 1:59api that's integrated through a third 2:00party so 2:02say you see someone makes a comment 2:03about the t-shirt and they're like 2:06man the t-shirt fit comfortable but the 2:0950 polyester really gave me a bad skin 2:11rash 2:12that would all be possible through this 2:14third-party integrated service 2:17so now that we've established our users 2:19and our clients 2:21now let's take a look at the actual 2:23product detail ui right so there's a lot 2:25of different functionality a lot of 2:27different tasks that we've broken down 2:29into these micro services here 2:31and this originally would be a 2:33monolithic application like we 2:35previously talked about but we've we've 2:36broken it apart and segmented it into 2:38different services so 2:40as you can see the first one here is the 2:42product info service this would be stuff 2:44like you know look at the t-shirt what 2:46kind of color is a t-shirt is it black 2:49red the size of the t-shirt large medium 2:52and so on 2:53and then we have our pricing service we 2:55have our order service if you want to 2:57look at purchase history you got the 2:59inventory service and the review service 3:01and so on and this is just a handful of 3:04different microservices here we could 3:06have many more so that's just a very 3:08quick rudimentary overview of direct 3:11client to microservice communication 3:13architecture 3:15so let's take a look at what an api 3:20gateway architecture might look like 3:22let's get rid of these 3:27okay so api gateway the topic of the 3:30hour so your api gateway would reside 3:33right here in the middle between your 3:35clients 3:37and your microservices 3:39and there are numerous benefits with 3:41implementing an api gateway solution i'm 3:44just going to go over just a couple main 3:45ones right now 3:47so the first main benefit is client 3:51performance 3:53i'm just going to put 3:54perf or short 3:57so in our last example we had our 3:59clients making a bunch of api requests 4:02to each individual 4:04microservice so in this instance with 4:06our api gateway which would essentially 4:08be like a reverse proxy or you could 4:10even consider it like a api traffic 4:13controller you would take those requests 4:16and then route them to the appropriate 4:18microservice 4:21so this has 4:23numerous benefits right because now 4:25instead of having all those individual 4:27requests go into each microservice now 4:29you can filter it through your api 4:30gateway 4:32and this reduces latency so now 4:35your product detail ui page will run 4:38much more efficient much faster 4:40and it's a better client experience 4:43because you don't have as many round 4:44trips right because our last example say 4:47you had a request come in it went to the 4:48product info service but you're pricing 4:51microservices speak with the product one 4:53so you would have to go back to the 4:55client back to pricing and so on so 4:58this reduces those round trips here 5:01and on top of just being a better you 5:02know client performance 5:04it also helps the development team as 5:06well because 5:07they don't have to manage and maintain 5:08all those individual api requests now 5:11they can do this all through the api 5:12gateway 5:14so the next main benefit is security 5:20so by having this api gateway right here 5:23we essentially have a security barrier 5:26in front of our front-end clients right 5:28our front-end api 5:29endpoints 5:31because otherwise 5:32we had everything wide open right and 5:34you're not susceptible to like a dos 5:37denial of service attack or any other 5:38malicious attack with this api gateway 5:41and you could add other services within 5:43this api gateway like authentication 5:45authorization 5:47to add another layer of security 5:52and this leads me to my next benefit 5:54which is protocol 5:57translation 6:00so if you recall 6:02we had to have the same internet 6:04friendly protocol 6:06going from our clients to the 6:07microservice in order for it to function 6:09and operate 6:10here we could say we have https 6:14that's again a secure credential 6:17but we can change the protocol here we 6:19could just go http 6:21for each 6:22api request that's routed and 6:25by removing the s and that secure 6:27credential where you don't have to 6:28authenticate this is ssl termination 6:31where the ssl stands for secure socket 6:34layer and this is a process where you 6:36decrypt and offload the encrypted ssl 6:38data within the api gateway instead of 6:40going to our backend microservices so by 6:43doing this this greatly helps 6:45performance of our e-commerce storefront 6:46as you can see 6:48although i don't know why we don't have 6:49any more spendiums you don't even have 6:52to have you know internet friendly you 6:53can even have server-side protocols like 6:56amqp so you have a larger reach right 6:58you have more usability with your 7:01e-commerce storefront because you could 7:03have other protocols 7:07the last 7:09quick 7:10benefit i want to mention is common 7:14functionality defunct offload 7:19so we're off floating 7:21these common functionalities for every 7:23market service that we had to have in 7:24order for it to operate right so now we 7:27can take some of that business logic and 7:28put in this api gateway 7:31you can just have your microservices 7:32running a little bit more efficiently 7:34and smoother because we're just focusing 7:35on their tasks that they really need to 7:36focus on they don't need all that other 7:38business logic so you could have stuff 7:40like rate limiting 7:42you could have tin requests for every 60 7:44seconds if you want to put a cap on that 7:46to help with demand 7:48you could also have stuff like api 7:51monitoring and logging if you want to 7:53keep it on the api health and how 7:55everything's working 7:56operational wise and there's just so 7:59much more 8:00and that's just a few there's a lot more 8:02standard features typically with an api 8:04gateway solution 8:06so this is great and all but what if we 8:08get an instance where say you get a huge 8:11spike in traffic and 8:13indy's custom thread is preparing for 8:16black friday oh my god we're going to 8:17get so much traffic what are we going to 8:19do you got users here you've got users 8:21here 8:22well 8:23we could install and implement a bff 8:26architecture 8:28and no i'm not saying best friend 8:30forever although i will be your best 8:32friend if you like this video 8:35i'm talking about back in 8:37to front and 8:40and essentially what this is is you're 8:43adding additional api gateways so for 8:45this one for instance this would be our 8:47dedicated 8:48web api gateway 8:51so here 8:52we could have one for our mobile devices 8:54right you could have another api gateway 8:57and this would just be dedicated to your 8:59you know native 9:00os and android devices 9:03and it would take all that api traffic 9:05coming for those devices and routing 9:07them to the right microservices 9:10and this is 9:11you know you could have this for the 9:12third party integration 9:14service as well and there's other 9:16clients as well you can have here you 9:18could have like iot devices with sensors 9:20right um so 9:22this is a great benefit if you're going 9:24to have a huge demand and spike with 9:26traffic or say you're just adding a lot 9:29more functionality and features to your 9:30your e-commerce storefront so this would 9:33be a great architecture to consider to 9:35expand and scale up 9:37so this is just a very quick overview of 9:39api gateway i hope you found it helpful 9:42oh and before i forget i didn't forget 9:44the t-shirt if you want to get it my 9:46question to you is 9:48what is ssl termination 9:51drop an answer in the comment section 9:53and then we'll make sure to ship you the 9:55t-shirt and we'll get your details 9:57through there so thank you so much for 9:58watching again i hope this high level 10:00overview has been helpful thank you 10:03if you have questions please drop us a 10:04line below if you want to see more 10:06videos like this in the future please 10:08like and subscribe and don't forget you 10:11can grow your skills and earn a badge 10:13with ibm cloud labs which are free 10:15browser-based interactive kubernetes 10:17labs