OwlTail

Cover image of Gareth McCumskey

Gareth McCumskey

18 Podcast Episodes

Latest 1 Oct 2022 | Updated Daily

Episode artwork

From South Africa to Portugal (The Algarve): Gareth McCumskey on the GMP!

The Good Morning Portugal! podcast with Carl Munson

Increasing numbers of South Africans are showing an interest in moving to Portugal. One such pioneer is Gareth McCumskey who has made the move to the Algarve, from where he'll tell us about his journey from Africa to Europe...---Carl 'Your man in Portugal' Munson is available for one-to-one consultations as part of Expats Portugal's Ask Our Expats team - https://expatsportugal.com/ask-our-expats-portugal/ABOUT EXPATS PORTUGALWe are an online community-driven website and forum offering help and advice to the English speakers already living in Portugal or planning to move here. We have been servicing our community since 2005. You will find articles, member benefits, real estate advice, events and more.Visit our site: https://expatsportugal.comSupport us by becoming a Premium Member: https://expatsportugal.com/upgrade/To be kept up to date with future webinars visit: https://expatsportugal.com/calendar-whats-on/View our forum: https://expatsportugal.com/community/Check out our English-friendly business directory: https://expatsportugal.com/business-directory/Proud to use Streamyard - https://streamyard.com?pal=4668289695875072

1hr 7mins

12 Aug 2021

Episode artwork

S2E8 - Gareth McCumskey on serverless-first, helpful services, and the backend of the Jamstack

That's my JAMstack

Quick show notes Our Guest: Gareth McCumskey What he'd like for you to see: Serverless' Components feature His JAMstack Jams: JAMstack and Serverless help build things with low-code. Check to see if there's a solution out there for what you need to solve a problem. His Musical Jams: Jinjer - Pisces This week's sponsor: Auth0 This week, we've got Auth0 as a sponsor. While their prowess at authentication is important, they're also releasing a ton of new tutorials and courses on their YouTube channel, including a free course on building a full-stack Jamstack app with Next.js. Transcript Bryan Robinson 0:03 Hello, everyone, welcome to another episode of That's My Jamstack the podcast where we ask the time honored question, what is your jam in the Jamstack? I'm your host, Bryan Robinson. And this week we talk with Gareth McCumskey, a serverless architect at Serverless Inc. Before we dive into the episode, though, I want to thank this week's sponsor off zero, we'll talk a bit more about the amazing educational content they're putting out at the end of the episode. If you're curious about that, Jamstack and author education, head on over to a0.to/tmjyt. That's My Jamstack YouTube for all the videos. Hey, Gareth, thanks for joining us on the show today. Gareth McCumskey 0:45 Yeah, thanks so much for having me. I just, I love talking about Jamstack stuff. So it was a opportunity not to be missed. Bryan Robinson 0:51 Cool. Well, you like talking about Jamstack stuff. But tell us a little bit about yourself? What do you do for work? What do you do for fun? Gareth McCumskey 0:58 So my work right now is essentially I'm a Solutions Architect with Serverless, Inc, the creators of the Serverless framework. And yeah, being a small startup means that I kind of do a multitude of roles like most folks in the in the company. So I I'm involved a lot with helping users have the framework design and and sort of plan out the systems there. They they plan on building with service. And the other side of it is as well as I act as sort of developer advocate in trying to help spread the word about serverless. And related stuff, I guess you can say, Bryan Robinson 1:33 That's kind of growing the whole the whole world so that you know, people who want serverless might come to serverless in the future. Gareth McCumskey 1:40 Yeah, absolutely. And I find a lot of folks will hear some brief inkling about serverless, not quite sure what it means. And because you know, we've been able to produce enough content, they get a bit bit of understanding, and then they have questions. So it's nice to be there. So for that, for that growth period that a lot of devs go through. And I guess on my personal side, I'm, I think very much into the computer world. So especially with the with the load with the global pandemic we've been going through lately. So I'm quite an avid gamer. Yeah, and it's just that's kind of that way I love steam these days. Bryan Robinson 2:14 Nice. Are you? Are you on the PC side on the console side are like kind of in between? Gareth McCumskey 2:19 Well, PC side, which kind of means I never leave the desk. But yeah. Bryan Robinson 2:25 What's your what's your go to game right now, especially with with pandemic round? Gareth McCumskey 2:29 Well as a typical developer story, where I play a game called factorio. I don't know if you've heard of it, but it's essentially an engineering style game where you build a factory and consume resources. And it's a massive problem solving things. So I go from working with developers all day long to basically running a little factory. Bryan Robinson 2:49 You know, from from software engineering to real engineering, in software. Gareth McCumskey 2:53 Yeah, something like that. Bryan Robinson 2:55 Nice. Alright, so so we're talking Jamstack today. So let's talk a little bit about what was your entry point into this world of Jamstack, or maybe static sites, I know you've been in the industry for a while? Gareth McCumskey 3:07 Well, it's one of those interesting situations I found myself in. And just a bit of context. So long story, here we go. I have had, I was a lead in a team at a tour company that basically sold all their product online. And with that, they had a platform that was built on WordPress that they've been using for about 10 years. So really showing its age really legacy when we're talking legacy. And when I joined, there were there were there being some serious issues with performance and science. So ultimately, we came to the point where we had to re architect pretty much the entire platform. But we needed a way to do things piecemeal as well, because we couldn't go down a rabbit hole for a year come out with something on the other side that maybe didn't fit, they need to start seeing some return on what we were working on. So initially, after spending a bunch of time looking at stuff, I found serverless, which was kind of my gateway into Jamstack side of things, and looking, looking at building, you know, the whole Functions as a Service became very attractive, especially when you're in a team of about two or three developers where none of you have massive DevOps experience. Myself, I can kind of spin up a web server when I need to keep it up to date. But you know, I wouldn't necessarily trust myself, you know, the massive production, cluster, and so on. So that became a little tricky first, and serverless seemed like the right answer for that. But serverless doesn't come without its own own way of doing things. And traditionally, for me, I had come from the world of big fat PHP frameworks that handled everything, you know, rendered rendered everything on server and push that out to the browser. So there's really going back to my roots when I was looking at serverless and realized that probably the best way to attack this would be to build back end API's with serverless and have a completely static front end running something like view or react or Whatever, and have that calling this API back, because the API back end is really where we were concerned about load the most. And this led us to start building a solution like this, where we could have a team focus on building a nice front end, and have a couple of guys building a front end. And myself, maybe, I think, was one of the engineers working on the back end, small team. And this works incredibly well, for us. We had an entire ci CD process, things were going really nice. And the first time I heard Jamstack, was about, I don't know, nine months into doing this, we attended a conference and somebody gave a talk about Jamstack. And the four of us sat in this talk looking at each other throughout this entire discussion going that's what we did. So it was very interesting way. And and I think one of the one of the key things that we talked about afterwards was how it was going back to our roots as as people building stuff for the web, seemed to be the best solution all along just building static HTML, JavaScript and CSS, and having API's to call to Bryan Robinson 6:03 Yeah, so an interesting thing that you kind of said, Kevin, in the beginning of this story, which is, I think, different from what a lot of people have said about their kind of intro into the Jamstack was, you actually started with this idea that we need serverless functions, we need Functions as a Service, whereas most people are saying, you know, hey, I am already using view or I'm already using react. So I got into this thing called Gatsby, I got into this thing called grid zone. And that was my entry point, or, you know, I like HTML. So I got into Jekyll or something along those lines. Where it said, where you're kind of saying, you know what, we don't want a monolith on the server, we want to break it up. And then oh, what are these other things we can do to attach it is that kind of a good representation of what you're what you were going there? Gareth McCumskey 6:50 Yeah, it was interesting, because there was some other things we were looking at sort of at the same time, I was really doing a big investigation into micro services as well, because this is back in 2016, as well, just to give it a little bit more context. So micro services was kind of new and coming out. And there's a few books written and it was growing in popularity. And when looking at microservices, the one thing that struck me instantly was how come out complex the infrastructure behind it looked. So microservices looks really complex for us to try and use. And we didn't feel confident in our skills, you know, in managing all this amount of infrastructure, as I mentioned, and servers just seemed a great answer for that. And very quickly, we realized that building a back end with something like serverless wasn't just about the Functions as a Service, because lambda was that new thing that I'd seen at AWS event which sort of struck struck me as well, and ultimately led me when I was investigating serverless, to realize that this was using lambda. But it's also all about the other services that you end up consuming as well, which you build upon. And that essentially replaces the need for this massive monolithic back end server. One of the things I point out to folks is that when you're building an application, there's really three, three main things that you need, you need some way to receive a request, some some HTTP endpoint, you need some way to compute, and you need some way to store data. That's ultimately and then of course, the fourth part, I guess, would be the response back, which would be the static pages that you're providing to user to, to consume. But ultimately, with an API, there's three components, we need to receive a request, you need to compute a response, and you just store data. And when you look at serverless, especially on the AWS side, which is what I'm most familiar with, you have AWS lambda, which kind of started a lot of this dynamodb, which ends up being a fantastic serverless Datastore. And API gateway, which becomes that front end that you need that can handle handle that scale and load. And then you've got your pick of the static, static site, web servers out there, everything from s3, to you know, there's a whole bunch of options out there to store static sites. So that's pretty cool. Awesome. Bryan Robinson 8:54 So So obviously, that was how you were using the Jamstack. Professionally, back when you were doing that, how are you using the Jamstack professionally now and also personally, personally? Gareth McCumskey 9:05 Yeah, it's interesting, I kind of use things in very similar way. So right now, pretty much all the sites that I build end up with a step by step all the front end sets in a statics store somewhere like an s3 with a cloud front in front of it. And the API back end, the difference has become the difference now is that the issue, I'm traditionally from the back end, so that's why my focus tends to be on on back end infrastructure. I just more adept at that, I guess. There's a lot of skill that goes into building a good front end and I just haven't had the time to really focus on that. I mean, it's a it's a massive world to delve into. But for example, my my back ends now for my API's tend to be microservices based, and with tools like like, you know, with the cloud and AWS and many other cloud providers as well. You can build really sophisticated back end services with Beautiful asynchronous communications between them. That lets you defer all sorts of load and issues that you may normally experience into asynchronous processes that kind of execute when they feel like it when they go capacity, which is fantastic. It just means that when you have that, that buzz of traffic at eight in the morning from your customers, because you sent them a mass email, you can handle what you need to the front end, because s3 or all these other site generators can handle the HTML and CSS they need to push out. But your back end is just deferring all the processing of the instance. It's a pretty interesting way to build things. Bryan Robinson 10:33 Yeah, it definitely it can. It can be kind of a web to weave in your mind, but it works incredibly well on the actual technology. Gareth McCumskey 10:42 Yeah, absolutely. I mean, doing things like receiving an API call. And it's interesting, because I've had this discussion with other folks as well, where they talk about things like you know, if somebody wants to edit their profile, this is a silly example where, you know, they change their email address, and they hit save, they expect that to be saved immediately. And when the page refreshes, they're expecting that to be the representation of what's in the datastore. In the back end, Meantime, it doesn't have to be, that could just be what's cached locally. And the front end knows, I've told the back into stores, it told me it's going to at some point, I trust it, I'm just going to tell the user This is what the email address is now because the beckons told me that's what it's gonna be, it's pretty optimistic way of, you know, storing these things. Meantime, that beckons been designed in a way that it's just absorbing all this traffic as it can. And yeah, things just work really beautifully. Bryan Robinson 11:29 And so I'm kind of curious. So I don't think we've had someone who, who's probably heavier on the back end. On the show, I think, I think for the most part, we've had some full stack developers, and we've definitely had a slew of front end developers. So if you were to talk to a pure back end developer, maybe like how you were 2015 2016, you know, having a big PHP stack or even like a dotnet, or something like that? How would they how should they think about transitioning to something like Jamstack, with, you know, various serverless pieces? Gareth McCumskey 12:04 Yeah, it's interesting, we had to do this actually, with the company that I was working for at the time. And one of the things, one thing I always suggest, first of all, is to start with a basic PRC, something, something that's concrete, so it's not meaningless, but not something that's critical. So you don't want to go PRC your checkout process, because that could affect the bottom line, bad idea. But we're seeing something like for example, we had a review system that people could leave reviews for the tours they had gone on. And the review system is important for the full conversion of sale. But if it happens to fall over, it's not the end of the world, people can still check out, we can still sell things on the site, and so on. So ultimately, that was our stepping stone into the world of Jamstack and serverless. we extracted this widget that we had in multiple places across the site, turned that into essentially a component for the front end, that had a back end component, which was an API. And that's how we how we proceed that just this one, one small component. And ultimately, that was a massive success for us, and proved out the technology. And we took the next step where we went through the site and looked at some of the content we had for things like the About Us page or company values page. And but that's the kind of content that does have changes at times, but changes very infrequently, it's not a product page that might change in you know, within within seconds with the price and reviews and any other information. So the next step was to extract those out, turn those into static pages with some kind of CMS back end, but not something that needed to be to the second with updates that you could let generate in the background whenever it needed to, and it would pretty much just sit there statically. And again, there was that there was the proof of concept for the front end. Now because we've just done a small component. Now we were proving the front end, and that worked beautifully. And just keep going up, then we started converting product pages, then we converted checkout. And you just keep taking these pieces at a time basically the strangler pattern. If anybody's familiar with that, we just take one piece at a time. And with a tool like CloudFront, or any other CDN cloud was what we were using at the time. CloudFront was set up to default to route so it would go to the WordPress installation by default. But we could use the URL structure of our site to break apart each piece one at a time. And initially, we were manually entering these URL endpoints like slash about us and they would point at an s3 bucket slash company values were pointed at s3 bucket route slash we just pointed the WordPress instance that was sitting on an easy to instance. So that allowed us to wait to sort of break things apart and point traffic at the right locations while we were building. Interesting. So Bryan Robinson 14:37 yeah, I don't think we've ever had anybody talk about about that. We've talked about like breaking up monoliths into micro services, but like literally breaking up the front end to is a very interesting thing like oh, I've got WordPress, we can't completely migrate away from it for X, Y and Z yet, but you know, our about page does need to be a database generated page, our company values like let's just redirect That VR CDN. And that's a really interesting take on that. What would you say is kind of your overall jam in the Jamstack? What's your favorite service? Obviously, you work for a service, that's a pretty big service in the Jamstack. But what's your favorite service? What's your favorite philosophy or framework, and then like, what just makes you love the gym? Second, it's gonna keep you working in this space for a while, Gareth McCumskey 15:22 huh? Where to begin? Alright, so I guess the biggest overall one, and we've really pointed out I'm very much sort of the back end guy. But the thing I love the most, and this is gonna sound strange being a guy who likes to build back ends. But I don't like code necessarily. It sounds bizarre. But code is is actually the weakest part of any application. And a lot of developers especially. But a lot of those are coming and raise their eyebrows at that, because that's what we get paid for it. And they want to get paid to write code. When really, it's not what any business wants. And I've it's taken me most of my career to realize this. But what most businesses want is they want a solution that solves the problems, they ultimately don't really care where it comes from, as long as it's reliable, and it's done within some reasonable timeframe and cost, then they're happy. And that's what Jamstack and serverless, as well just, you know, as part of that has really helped me build with all the solutions that I have. I, I normally, you know, espouse the mantra of serverless, first or Jamstack. First as well, I mean, that's one way to look at it is, instead of writing code first first solution, see if there's an existing service out there that can solve the problem for you. And usually, it's going to be reasonably priced and paper use. So you don't have to worry about this massive, you know, albatross around your neck. And ultimately, what it gives you is a way to solve a problem that you don't have to maintain over time that you don't have to make sure that whoever you hire into the position will know how to work on and code for. And a simple example of this is if you look at a very basic API, for example, with something like API gateway, a lambda function and dynamodb, the lambda function itself is probably going to end up being if you have a simple crud application, let's call it a create user endpoints as an example, if you have a POST request for that you set up API gateway API gateway is going to receive an HTTP request, it's going to handle the HTTPS for you, you can configure API key, so you can restrict or restrict access to it automatically. You don't have to worry about that. It will manage load for you. There's no load balancing involved in it at all. I sound like I'm selling API gateway. But I'm just talking to the the basic features of an API gateway. But the biggest thing that it does as well is routing. And often routing has been one of those things left for the big fat frameworks to do for you in code, which sounds great, except now you have a dependency on code that somebody else managers, whereas now with something like API gateway, this is a running service inside a cloud vendor that is executed as nothing, you don't have to worry about that open source project, maintaining the routing mechanism, this is done as part of a service, it's built for you. That's that's the way it works. What this means is my lambda function now isn't isn't resolving routes, it's just receiving event data, it's just receiving an HTTP request. And similarly, if you if you look further down into data storage, using a tool, like Dynamo dB, for example, is a key essentially, at its most basic form is a key value data. So it's a little bit more advanced than that. But we just say that for now. What's really nice about this is that it has an API, a very simple API that you can send requests to. And ultimately, there is no ORM necessarily involved. So you're writing a basic API calls to a Datastore in the back end, and a lambda function is going to probably be about a 10th of the size of your regular amount of code that you would have sitting in even a non monolithic framework these days. So that for me is the biggest one is the reduction in code. Bryan Robinson 18:48 Yeah, and I think I think that's an interesting way of putting it too, because anyone who's viewed my code, at least knows this the weakest link in my application. But on top of that, like if you look at it, and you say, you know, I'm, I'm a web developer that excels at writing, x type of feature, but you know, what I'm really bad at is writing off, like auth is an incredibly complicated, very security, heavy specialization in code. I should not be writing that, oh, I can go find you know, one of these two or three, four different services that will provide off for me in a very compact API driven way, which I think, is probably for the best for a lot of web developers out there. Gareth McCumskey 19:29 Yeah, that's one of those things. I think developers are really bad at writing a really bad security. And it's no fault of developers. It's actually a fault of our education in the industry. It's kind of like, I'll worry about security when I'm done. Which is probably not what you should be doing. But you know, that's this way we have problems to solve. We have solutions to build the worry about securing it later. But yeah, mean things like auto will will hand you essentially an entire solution to handle auth and I've built my own custom authorization services even in the gem stack itself. It's not an easy task, you're constantly maintaining it even, I'm maintaining it to this day. Unfortunately, if I just used the service that was available to me, I probably wouldn't have to do that I'd saved myself a lot of time and effort. And my, you know, the users of the system would be probably a lot happier to. Bryan Robinson 20:16 And you even mentioned something, something that the nowadays at least with a lot of the modern tooling scene, you know, super easy, right, which is managing HTTP versus HTTPS. But like, even three, four years ago, you know, I was managing servers and having to, you know, deal with, okay, well, let me figure out, Let's Encrypt, and let's make sure that that bot is running at the appropriate speed and the appropriate time. And that was a huge headache. And now it's literally just a Boolean field in, you know, most of these cloud providers, like, yes, please handle HTTPS for me. Gareth McCumskey 20:47 And even I mean, I've been around in the days before, Let's Encrypt. And that was, that was an absolute nightmare. It actually got to the point, I don't even know how to set up HTTPS anymore on a on a web server, because back then I would go down that rabbit hole handed over to the to the sysadmin. To finish it up for me, because I was pulling my hair out. Let's Encrypt, solve that problem to a large degree for servers. But it's still not an easy task. And it's something you have to either set up an automated process for or come back to every three months to renew those certificates. But you know, the cloud vendors just completely take that away from you again, it becomes so much easier to set up. Bryan Robinson 21:22 I mean, granted, it was my entry point and the learning how to do cron jobs and some other stuff. I I owe some education to doing SSH. But yeah, it was a SSL it was it was definitely a trial in a lot of ways. So what would you actually say in terms of musical jam, what is your musical jam right now? What's your favorite song or your favorite musician? Gareth McCumskey 21:43 So lately, I've gotten into a new band, and I've always been a bit of a metal head. So anybody who's not into into that kind of music, I do apologize. But lately, there's a really great band of heard called Jinja. And anybody who's not familiar with them, I would suggest looking up the song on YouTube called Pisces. By ginger, it's a nice surprise when you get to watch that it's pretty infamous in YouTube circles now for being one of those react. videos that you surprise a YouTuber with? Yeah. But yeah, it's it's it's just one of those bands that have really impressed me with their, the entire band. I mean, the the vocalist, she's absolutely incredible, has an amazing voice. And just ultimately, the entire band works together, like an oiled machine. They're absolutely amazing at what they do. It's what it was one of the things that really impresses me is when an entire band works together so well that not a single one of them sort of stands above the others. They're all just absolutely awesome. Bryan Robinson 22:40 And that takes a lot in the in the music world not to have that ego to like be able to mesh like that. Gareth McCumskey 22:45 Yeah, it's always nice to see their interaction on stage and so on as well, where they're all trying to have their moment in the in the in the sun essentially trying to show what they can do. without it being, you know, over the top. Bryan Robinson 22:56 It's not It's not the 15 minute drums. All right. Yeah, exactly. Nice. So. So is there anything that you'd like to promote and get to the Jamstack something you're doing or something serverless wants to talk about at all? Gareth McCumskey 23:08 Well, from the service side, there's something new that I can mention. Front End, folks, as you mentioned, there's a large audience of front end developers that listen to the show, where I've been on the show, at least as well. One thing I can mention that that is really great is that we're in the middle of working on a really great project called components right now. And this is different if folks have known the serverless framework from 2015, we released the the actual serverless framework itself, it's a fantastic tool, it does a lot of great stuff, a building, for doing back end work, and so on, help orchestrate all of these services and so on in AWS. But what we found is that while it's great at doing that, and it simplifies things a bunch serverless as a concept is very new and different enough that it's kind of a barrier to entry for a lot of folks. And especially if you're not already a if you haven't been building backend solutions for a long time. It's unfair, just you know, I, I would have no one would expect me to just dive right into view and react and angular know my way around in exactly the same way that you know, there's there's a lot of stuff when dealing with with back end code and applications. But one of the things that components does is that it takes the idea of serverless and boils it down into a nice consumable package with very little configuration. And you can actually go to the point of configuring a solution in serverless, with about three lines of configuration, a single COI command, and you've essentially deployed your Jamstack application into the cloud. Yeah, it's it's actually pretty awesome. I've been playing with it a lot myself. And we are actually it's one of those things we built for other teams and we're using it ourselves now. And it's it's really also because what it and this is the sounds like hyperbole, but it really isn't because ultimately I can go to Can I can I drop a URL? Oh, yeah, go for it. So if folks can just go to Apple serverless.com, which is our online platform, and once you've signed up, you can go and create with any of the existing components. And there's new ones coming out all the time. But one of the ones I can point to as for example, the full stack application, which ultimately what this gives you is a command to run in the CLR to install and initialize your your application that you want to create your full stack app. And this full stack app contains essentially four components. One is for a front end. So we call it the website component, the other. The other is an express API. So if you know anything about Express, you can actually just spin up your own sort of Express back end within it as an API, database component for Dynamo DB as well as permissions that set up all the permissions you need in AWS. And you can just go in and you can, you can deploy it immediately because it has a working front end back end and everything else that it needs. And just play around with it in your own AWS account. Or you can go ahead and edit it, you can point it at your own react, view, whatever code, when you run the deploy command, it'll automatically build your front end, it'll automatically connect to AWS, and push everything into s3 into lambda into API gateway, all these things that you need to run this application and then give you a URL CloudFront URL at the end for you to go and try your application. It's it really is as simple as that. Bryan Robinson 26:16 That's very cool. Because I find that one of the one of the easiest ways to get into new technology, especially new architecture, technology is to find an opinionated source, and then like use that opinionated source editor until I feel comfortable with it, and then kind of I can roll my own at that point. Gareth McCumskey 26:31 Yeah, and that's exactly the point. Over the years, we've seen a lot of folks come into service with Express as an expectation. And while the Solas framework can be used to deploy Express applications, just as they are, it's kind of a bit of a bit of a faff to use. It's, you know, you've got to configure things, you've got to configure things a certain way, you know, it becomes a bit of a hassle. So I deal with the Express component, for example, is that you can literally just pointed at that f.js file, which contains your your Express routing, and off it goes, it's into lambda, and works as intended. And the idea there again, is, as you said, folks, we'll get into this, they'll start using their application, things will run well. And that's the other the other thing that was difficult for me to figure out about this philosophy that you asked me before, because Jamstack and serverless is incredibly forgiving, you can do things kind of okay, and if it runs well anyway. And if it doesn't, if it stops running, well, you can tweak it in ways that'll make it run better. And once you once you become steeped and understand the technology, you can then rebuild pieces of at a time because that's what you did. Anyway, you started building pieces, you could replace those pieces with more optimized versions of them later down the road. And it becomes incredibly easy to do that. It's so super forgiving. Just try stuff out. And that's where a lot of folks will come and say, you know, how do I get into doing serverless? I said, Just try it, just do something with it. Even if even if it's gonna be even if it's the worst possible solution you could think of building with serverless it's probably gonna still gonna work and I'll probably still work. Okay. And that's okay. Okay, it's fine. Just change it later. Bryan Robinson 27:58 Yeah. Okay, means that you have shipped something that somebody needed. And it's out there. Gareth McCumskey 28:03 Yeah. And yeah, your users all they want is a working solution. They don't necessarily need the best crafted, highly engineered, fanciest solution that you can come up with. They just want something that works. All Bryan Robinson 28:15 right. Well, Gareth, I appreciate you coming on the show today. And I hope you keep doing some amazing things at serverless as well as just kind of in the in the general web dev back end world. Gareth McCumskey 28:24 Yeah, well, that's the goal. I'm hoping we can get there. Bryan Robinson 28:31 Thanks again to Gareth, for the awesome conversation. And thanks to you our dear listeners for tuning in Week after week. Be sure to star heart favorite or you know, review or whatever in your podcast app of choice to spread the word. Now a sponsor time. This week, we're lucky to have off zero back as our sponsor. Author is an amazing authentication platform, but they also have a wealth of amazing content coming out regularly on their YouTube channel, including a free course called full stack Jamstack with next js. If you're interested in learning more about next, taking the Jamstack further or authentication on the Jamstack head over to a0.to/tmjyt that's That's My Jamstack YouTube, TMJ YT for all their YouTube videos. Bryan Robinson 29:16 That's it for this week. Until next time, keep doing amazing things on the web and keep things jammy Transcribed by https://otter.ai Intro/outtro music by bensound.com Support That's my JAMstack by donating to their Tip Jar: https://tips.pinecast.com/jar/thats-my-jamstack

21 Oct 2020

Similar People

Episode artwork

#24 - Gareth McCumskey Solutions Architect at Serverless Inc.

Talking Serverless

This episode host Ryan Jones is joined by Gareth McCumskey, a Solutions Architect at Serverless Inc. Gareth is based out of Cape Town Area, South Africa, and has spent the last 4 years building serverless applications. Before serverless, Gareth came from a more traditional PHP and Symfony web development background and has been a web developer in some form for nearly 20 years. Hear about his experiences with migrating to the cloud, the challenges he sees for serverless in the future, and the advice he'd give people jumping in themselves. For a full list of our episodes check out talkingserverless.io it's all there and always free~*  --- Send in a voice message: https://anchor.fm/talking-serverless/message

36mins

28 Aug 2020

Episode artwork

JSJ 440: Why Serverless with Gareth McCumskey

JavaScript Jabber

Join the 30-DAY CHALLENGE: "You Don't Know JS Yet"Gareth McCumskey, a Solutions Architect in Cape Town, South Africa engages the panelists of JavaScript Jabber in an informative discussion about the broad topic of serverless. The JavaScript expert explains that serverless is essentially a way to use the existing managed services of the cloud in building a solution. He expounded on the different ways in which to employ the use of serverless.Panel AJ O’Neal Charles Max Wood Steve Edwards Dan Shappir GuestGareth McCumskey SponsorsScout APM | We'll donate $5 to the open source project of your choice when you deploy ScoutReact Native Remote Conf 2020PicksGareth McCumskey: Follow Gareth on Twitter > @garethmcc  Oryx Pro - System76 Full-Stack Application Development on AWS (Free Video Course) AJ O’Neal: Follow AJ on Twitter > @coolaj86 webinstall.dev Serviceman | webinstall.dev Pathman | webinstall.dev Steve Edvards:The Black Stallion (1979) - IMDbCharles Max Wood:Devchat.tv Remote ConferencesFollow JavaScript Jabber on Twitter > @JSJabberSpecial Guest: Gareth McCumskey.

1hr 25mins

14 Jul 2020

Most Popular

Episode artwork

JSJ 440: Why Serverless with Gareth McCumskey

All JavaScript Podcasts by Devchat.tv

Join the 30-DAY CHALLENGE: "You Don't Know JS Yet" Gareth McCumskey, a Solutions Architect in Cape Town, South Africa engages the panelists of JavaScript Jabber in an informative discussion about the broad topic of serverless. The JavaScript expert explains that serverless is essentially a way to use the existing managed services of the cloud in building a solution. He expounded on the different ways in which to employ the use of serverless. Panel AJ O’Neal Charles Max Wood Steve Edwards Dan Shappir Guest Gareth McCumskey Sponsors Scout APM | We'll donate $5 to the open source project of your choice when you deploy Scout React Native Remote Conf 2020 Picks Gareth McCumskey: Follow Gareth on Twitter > @garethmcc Oryx Pro - System76 Full-Stack Application Development on AWS (Free Video Course) AJ O’Neal: Follow AJ on Twitter > @coolaj86 webinstall.dev Serviceman | webinstall.dev Pathman | webinstall.dev Steve Edvards: The Black Stallion (1979) - IMDb Charles Max Wood: Devchat.tv Remote Conferences Follow JavaScript Jabber on Twitter > @JSJabber

1hr 25mins

14 Jul 2020

Episode artwork

JSJ 440: Why Serverless with Gareth McCumskey

Devchat.tv Episode Roundup

Join the 30-DAY CHALLENGE: "You Don't Know JS Yet" Gareth McCumskey, a Solutions Architect in Cape Town, South Africa engages the panelists of JavaScript Jabber in an informative discussion about the broad topic of serverless. The JavaScript expert explains that serverless is essentially a way to use the existing managed services of the cloud in building a solution. He expounded on the different ways in which to employ the use of serverless. Panel AJ O’Neal Charles Max Wood Steve Edwards Dan Shappir Guest Gareth McCumskey Sponsors Scout APM | We'll donate $5 to the open source project of your choice when you deploy Scout React Native Remote Conf 2020 Picks Gareth McCumskey: Follow Gareth on Twitter > @garethmcc Oryx Pro - System76 Full-Stack Application Development on AWS (Free Video Course) AJ O’Neal: Follow AJ on Twitter > @coolaj86 webinstall.dev Serviceman | webinstall.dev Pathman | webinstall.dev Steve Edvards: The Black Stallion (1979) - IMDb Charles Max Wood: Devchat.tv Remote Conferences Follow JavaScript Jabber on Twitter > @JSJabber

1hr 25mins

14 Jul 2020

Episode artwork

#13: What's new from Serverless Inc. with Gareth McCumskey

Real World Serverless with theburningmonk

You can find Gareth on Twitter as @garethmcc.Install the Serverless framework here, and don't forget to check out Gareth's full-stack Serverless course here.For more stories about real-world use of serverless technologies, please follow us on Twitter as @RealWorldSls and subscribe to this podcast.Opening theme song:Cheery Monday by Kevin MacLeodLink: https://incompetech.filmmusic.io/song/3495-cheery-monday/License: http://creativecommons.org/licenses/by/

33mins

26 May 2020

Episode artwork

Episode #46: Serverless Use Cases with Gareth McCumskey (Part 2)

Serverless Chats

About Gareth McCumskey:Gareth McCumskey is a web developer with over 15 years of experience working in different environments and with many different technologies including internal tools development, consumer focused web applications, high volume RESTful API's and integration platforms to communicate with many 10's of differing API's from SOAP web services to email-as-an-api pseudo-web services. Gareth is currently a Solutions Architect at Serverless Inc, where he helps serverless customers planning on building solutions using the Serverless framework as well as Developer advocacy for new developers discovering serverless application development. Twitter: @garethmcc LinkedIn: linkedin.com/in/garethmcc Portfolio: gareth.mccumskey.com Blog Posts: serverless.com/author/garethmccumskey/ Watch this episode on YouTube: https://youtu.be/5NXi-6SmZsUTranscript:Jeremy: One of the things that I know I've seen quite a bit of is people using just the power of Lambda compute, to do things right? And what's really cool about Lambda is Lambda has a single concurrency model, meaning that every time a Lambda function spins up, it will only handle a request from one user. If that request ends, it reuses warm containers and things like that. But, if you have a thousand concurrent users, it spins up a thousand concurrent containers. But you can use that not just to process requests from let's say frontend WebSocket or something like that. You can use that to actually run just parallel processing or parallel compute.Gareth: Yeah. This is one of what do they call it, the Lambda supercomputer.Jeremy: Right.Gareth: You can get an enormous amount of parallel... Try to say that three times quickly. Parallelization with Lambda. I mean, like I said, by default you get a 1000 Lambda functions that you can spin up simultaneously. And if you ask nicely... Well, you don't even have to ask nicely, just ask them and AWS will increase that to 10,000 simultaneous. And it's really impressive how much compute you can do, to the point where, at one point I was working with a company looking to try to do some load testing of an application.They had an instance where, on Black Friday, the tech kept falling over. They wanted to try to get some load testing in beforehand to make sure that it can handle at least a certain amount of volume. Because you can never entirely predict what your traffic patterns will look like. But at least let's try something. And they spend a lot of time looking at commercial solutions out there because there are a few of them out there that try to help with that.And they normally try to do about 500 to maybe a 1000 simultaneous users or simulated users, which is impressive but not quite good enough when you're an organization that's going to be having 10,000 to 20,000 simultaneous users on your site at a time. That gets a bit rough. So the move was then to try and build some load testing application ourselves. And this was initially tricky to do because we were trying to do this using the traditional VMs, virtual machines, and containers in some way, try to get EC2 instances up and running to try and run multiple simultaneous users at a time, in a single VM, using essentially a combination of these end to end testing tools where you can simulate a user flow from loading the homepage to going to a product page, adding to cart, going to checkout. Doing all of this on a staging environment so that you could simulate the whole user for all the way to purchase, the sort of main line to purchase as it were, make sure that you could get a few thousand users all the way to there without issue.And what ended up happening was these virtual machines just couldn't cope with the load of all these simultaneous users running on a single machine even with inordinate amounts of CPU and RAM on them. So the idea came to us to try and do this with Lambda instead. So what ends up happening is, because you have a thousand simultaneous Lambda functions, AWS also architects this in a way that the noisy neighbor effect of all of these Lambda functions is almost nothing. You can't say nothing.There has been some research I've read that shows there is a bit of a noisy neighbor effect between Lambda functions. But one interesting thing that we found was this is reduced when you increase the size of your Lambda functions to the maximum memory size, which is pretty cool. Because then uses an entire machine essentially or virtual machine as it were. So now you're limiting the effect of that noisy neighbor effect happening. Which means you can then also run 10 to 20 simultaneous users on that single member function with that enormous amount of size.And if you have a thousand of those, well now you've got a thousand Lambda functions with 10 to 20 users per Lambda function, running an end to end test, pointed at a single staging environment. That's a pretty powerful bit of load testing you can perform there. And Lambda being as flexible as it is, we needed to import a binary to execute the end to end testing framework that we were using.So you can use Lambda asynchronously to help you spin up the required binaries, import all of these items in and then synchronize the start of the tests through SNS, for example, which can just fan out the go command to all of these Lambda functions waiting to execute. And that was it. We have 15 to 20,000 users, load testing and application. And that's going to tell you whether you're ready for Black Friday or not.Jeremy: Right. Yeah, no, I think it's an awesome use case. And I mean the parallel load testing, I mean, just the amount that you can get. I mean even you try to run something on your local machine and you're trying to do just to simulate some things. You only have so many threads that you can open up, so many users you can simulate. And to do this reliably, I mean, some of these testing sites, you can go and get some of these... Use some different sites to do it.But they get pretty expensive if you want to do regular tests. If you run a thousand concurrent Lambda functions, even at the maximum memory, and it takes maybe five minutes to run your full load test, you're talking about a couple of dollars every time that runs. Right? I mean, so the expense there is amazingly low. I think that's a super useful use case. There are some more specialty things though that you can do with Lambda.And Lambda is very, very good at, or I should say Lambda is built to receive triggers, right? Serverless is an event driven system. So there are all kinds of triggers for Lambda functions. And I'm sure we probably could talk about a thousand different ways that you could trigger a Lambda function and do something. Everything from connecting to an SQS Queue to like you said, the DynamoDB streams and things like that.But one of the interesting triggers for Lambda functions, is actually getting an email that is received from SES, which is the Simple Email Service that AWS has. and I find this actually to be really interesting. You did something interesting with that.Gareth: Yeah. We worked with an organization who essentially they handled requests for medical insurance. So other companies would send this organization an email with information about users who needed medical insurance. And these emails are usually pretty similarly formatted. They were structured almost exactly the same, just with user information that was slightly different every time. And it was getting very tedious for them to have to constantly go into this inbox, troll through all these emails and then manually insert them into a CRM system, so that the sales team could later get back to these folks and help them sort out their medical insurance.So one of the things that they initially did before we came along, was they had a virtual machine essentially running that was a regular old email inbox and a script that ran every five minutes on cron that would then log into this inbox pull all these emails out, and try to parse them and then insert them into their CRM binaries API. Anybody who's done that kind of thing would realize there's quite a few flaws in that potential process, because not only do you potentially have thousands of emails you've got to pull in in five minutes before the next cron runs, but how do you keep track of which email you've already read.And the issue there is as well, this inbox was used by humans as well. So you couldn't use the red flag on the inbox as well, because a human might've clicked on an email and then you completely miss this lead in the first place. So it was kind of a problem to solve. So ultimately, the solution ended up being, registering a new sub domain on their email domain. And then just informing the partners that the email address to send these leads to had changed. And this email address was actually created inside of SES, Simple Email Service, which has a way for you to create a way to receive emails.You can create inboxes in SES to receive mail. And then you have a process you can set up and how to manage these emails. So, various methods you can do with these emails, the one that we ended up choosing was taking the email and storing it as an item in an S3 bucket. And this is where these triggers then happen. Anybody who's looked at serverless has seen the Hello World equivalent of serverless, where you can use S3 buckets to create thumbnails of images. But you can trigger anything in S3.So if you drop an email into an S3 bucket, that can trigger a Lambda function. So what's useful here is that we have a system that's receiving an email, puts those into an S3 bucket and that specific object put, spins up a Lambda function with all the detail of what this item is. The Lambda function that's triggered can read that email straight out of the S3 bucket and then process it just like it was doing before. It can pass through this email, get the user's contact information and then put that into that CRM that they need in order to get in touch with folks.And again, there's no worry here about have we read this email before. This isn't a human readable inbox. This is only used through SES. So there's none of that concern. And again, this is all entirely serverless. SES is going to receive your email at what pretty much whatever quantity you need, and they were receiving a few thousand emails a minute. So it became quite a big deal. And S3 as well has enormous scale that you can just use. You can just insert all of these items. Lambda can just scale out and process all of these items individually, pretty handily.What actually ended up being the problem was that their downstream CRM couldn't handle the load at one point, so they had to have an upgrade. But that's a different story.Jeremy: Well that's a common problem I think with serverless is that it handles so much scale that the downstream systems have a problem. So that use case though, this idea of receiving emails, dumping them in S3, reading them in with Lambda, there are just so many possible use cases around that. So the medical thing I think is interesting, parsing it, trying to get it into a CRM.But if you wanted to build your own ticketing system, like a support ticketing system. Now again, I wouldn't suggest you do that unless you're like building a SaaS company that's going to do it. But if you're building a SaaS company that has a ticketing system component, this use case is perfect for it. I mean, it's great. And then I actually saw quite a while ago, somebody built an S3 email system, like an entire email server using just S3 Lambda and SES.So essentially when the message came in, it gets processed by Lambda function, the Lambda function would read it. It was just sort of a catch-all address, Lambda function would read who the "to" was from and put it in the right box for it. It's amazing. So I think that's a really, really cool use case. I think you could handle attachments and all kinds of things like that that you could do with that, run algorithms on them, send them into SageMaker and do machine learning. I mean there's all kinds of things that you could do that would be really, really cool around that.Gareth: There's also the idea... I mean, the ideas that have crossed my mind and you think about all these triggers that you could potentially do, and all the services available in AWS to do them with. And I even picture an idea where you could talk about a ticketing system and combine this with a CRM type system where you're receiving a constant communication with customers. And you can send this through, I forgot the name of the AWS service that does sentiment analysis on text.Jeremy: Yes. Yup.Gareth: So you can just use that to do sentiment analysis. And you can have managers in a customer services team get notified when there's a certain proportion of customers that have a sudden mess of a negative sentiment. And you can start investigating before, even though there's a problem you've picked up from customers that there is a problem to go and solve. You could even do this with voice, because of AWS's sort of call center service. You can pass that through a sentiment analysis machine.And again, all of this stuff is built in serverlessly. You can trigger all of these things just as they happen automatically event based, really.Jeremy: I hope this has got people thinking, because we clearly are not going to have enough time to cover all of these use cases. But there's a few more though that I'd like to talk about, because I think these are broad that you could use for... And you can think of your specific use case for them. And one of those is cron jobs, right? Like cron jobs are...They're the Swiss army knife for developers. Like we use them for everything.We use them when we're like, "Hey, these log files keep filling up on this server. Let's run a cronjob and clean them up every couple of days or whatever it is." We use them to trigger ETL tasks. We use them to trigger all kinds of different things. And that is a really, really good use case for serverless, especially if you want to run something sort of peripheral to your main application.Gareth: Yeah. And cron jobs funny enough is probably the second most common use case I think we've seen with serverless applications, because I think every developer has been in that situation where you've got your main stack of stuff, sitting there doing your web stuff that you need. And you suddenly realize you don't really have any way to run schedule tasks. You spin up a little T2 small, EC2 instance somewhere to run some basic cron jobs, that might just call it an API end point at some point.But you need that capability to schedule things on a permanent, hourly, daily whatever basis to run those things. And that's where services like Lambda for example, become incredibly useful, because you can just schedule a cron job or a schedule onto a Lambda function, and then have it access all of the AWS services that you'd normally access. And a lot of the times the cron job's fed everything from sending regular email, because often you'd have a management that wants a status update sent for certain metrics. So you build a cron job for that. A lot of the times before you realize the wonder of SQS as a queuing system, you might build your own little queue system in a database table and you use a cronjob every few minutes to run over there. That kind of thing happens. So again, Lambda functions become really useful for managing all of these sort of scheduled cron jobs that you need to execute.Jeremy: And combining cron jobs with other things. Like let's say every hour or something like that, you want to trigger something that anybody who's on your website, something gets pushed to them or whatever. If you've got WebSockets set up right, like can just run a cron job and you do that every hour. The ETL tasks I think are an excellent use case for the cron job things. And then you actually did something with some XML feeds, right?Gareth: Google Shopping feed is one of these things that Google provides for you to advertise your products. Again, this is part of the e-commerce platform that I was working with. Google Shopping has the ability to read an XML feed of your products, but this feed needs to be built. And one easy way to do that is because the details of your products don't change all that often. I mean a shirt is a shirt, and a pair of shoes is a pair of shoes. You can build this feed ahead of time.So cron jobs is a great way of pre-rendering this XML feed so that when the Google Shopping spider comes along to read the XML feed, it's always available for you. And in this particular case the organization was using Magenta as their e-commerce backend. So instead of building the features on top of the existing stack, we were able to build a serverless sort of side project to handle this, so that we didn't have to make these changes to the existing stack and potentially cause issues there.And Google could just come at any time and constantly read this shopping XML feed or because of a XML data built ahead of time with a cronjob.Jeremy: Yeah, and I love that too, where you use Lambda to do the compute, and it doesn't touch the rest of your stack. I mean like if you're generating reports or something like that every night, do you really want to be using CPU power that runs alongside your application? That's handling requests from your users to generate what could be very CPU intensive. And that actually leads me to this next use case, which is this idea of sort of this offline or async processing. And you had mentioned, asynchronous in the past.Like that's the idea of, API Gateway sends a request to SQS, SQS which is a Simple Queue Service grabs the message, replies back to the API, "Hey, I got it." Which replies back to the user and says, "Okay, we've captured it." But then you've got something else down the road, that might require more processing power than you would want to do synchronously, right? Like, you don't want to generate a big PDF or convert a bunch of thumbnail images.You don't want to do that in real time, while the user is waiting on the other end of an API. You want that to happen in the background. Right? So as a background task. So this idea of offline or async processing, like what are some of the other sort of things you can do with that?Gareth: Well, you've mentioned a few of the use cases already, and one that I've ended up working on was a project where users were able to upload images into the application. And one of the things that had to be done to these images was essentially a uniqueness hash calculation on them. And this essentially scans through the pixels of the image, and then calculates sort of a string-based hash that you can very quickly determine if you have another image in library that has a certain similarity level.So you can also tweak how similar you want all these images to be. But this is a pretty intensive process and can take 10 to 20 seconds in some cases depending on the size of the image. And you don't want this kind of thing happening synchronously on upload. So use it as an upload the image and sit around waiting for 10 to 20 seconds, until this hash is calculated. So what's here is that you have for example, an S3 bucket and we kept talking about S3, but it's the workhorse of AWS. It does so many things so well.But again, you can trigger asynchronous offline style processing by dropping this image, for example, into this S3 bucket. And then either through a cron job as you mentioned before, or just triggering off of that put objects action that gets generated by S3 bucket to a Lambda function. You can then trigger these calculations. And this can run the gamut. It's not just this hash calculation I'm talking about, but you mentioned PDF generation. So you can have dynamically generated PDFs made available to the public when things like a DynamoDB table is edited.Now in the background, it receives that event trigger to a DynamoDB stream that the data has changed and it starts rebuilding PDFs. Maybe there's multiple of them. And you can combine this with the power of something like SNS or EventBridge that you can trigger multiple Lambda functions, each rebuilding a specific PDF because of one data change that you made. Very powerful ways of doing these things.One of the other useful ones that I've used in the past is we were talking about the whole Jamstack style process before. But a lot of cases, if you look at a lot of web frontends, there's many pages that often never change in their content, or very rarely change in their content. And in those rare circumstances where somebody has come to edit the contents in a CMS style. You can, instead of having a WordPress style CMS that you click a save button and the content is instantly changed.You can instead save that in some kind of headless CMS system, for example, that can then trigger off a Lambda function to pull in this new content and rebuild the static HTML, JavaScript and CSS that page consists of and push that into an S3 buckets. And this is a CMS, a type of system that we built in the past with asynchronous processing, because you don't really need that page to be updated, the instance somebody hits a save button.But you do need it to be updated within a reasonable amount of few... Maybe a few seconds is more than enough. And then you have the entire power of a Jamstack that can manage this enormous amount of load, loading static content, but still have that asynchronous process and to make pages dynamic as well. Pretty useful.Jeremy: Yeah. Love that. Love that. So the other one that I really like, you mentioned that image hash. In order to figure out the differences between images. Actually did one of those again several years ago. But I know really has nothing to do with serverless, but it is a really, really cool little algorithm that you can write that essentially you reduce the quality of the image to 10 x 10 or something like that, take an average of the pixels and then you can use each pixel to determine... Make it black and white and so forth or gray scale. That's a very, very cool... It's a very cool algorithm that you can write. So definitely check that out if you're interested in running image hashes.Gareth: The other interesting thing is if you combine these kinds of scenarios with something like CloudFront and Lambda@Edge this isn't necessarily asynchronous processing, but this is a way to... AWS actually has an example architecture where they combined Lambda and CloudFront to do thermal generation on demand. Which is a very interesting pattern to also take a look at where you have a base image. It might be your monstrous 4K image that is 20 megabytes in size. You don't want to serve that in a frontend, but you want this to be your source for all of the other images.And you could use you can use a CloudFront and Lambda@Edge to receive a request for this image. And with Lambda@Edge you can intercept that request for the image. And often this is done with a unique URL. So you can have a URL that says something like thumbnail/ and a specific size, written somewhere in that path. Extract that information out of the path. Realize that the image that this URL references is this enormous one sitting in your S3 bucket.And pull that out of the S3 bucket, resize that to the correct size you want, so that it's much smaller and return that to the user, and immediately CloudFront is going to take this much smaller image and cache that. So the moment that the next request... Because the first request might take a second or two for that whole process to happen. But the instance you do that the first time it's now cached in CloudFront and the next request that comes in for that size dimension, it's already done but you haven't consumed any extra space in S3.It's all just an item sitting in CloudFront. So you could even clear your CloudFront cache and reset all those images. But again, you haven't incurred the cost of additional items sitting in your S3 bucket that you need to worry about managing last cycle. This is all just managed in CloudFront for you.Jeremy: Yeah, that's great. We didn't really talk at all about edge use cases. But obviously there's the ability to do things like, I shouldn't say obviously, because this might not be obvious to people, but you can run a Lambda function at the edge. So you can do AB testing, you can do redirects, you can do blocking, you can do blacklisting, you can do... There's a million use cases around just the edge itself.But anyways, so we're running out of time here and I do want to get to one last one, which is the, I guess the proverbial thorn in serverless's side, if that's the right way to say it. And that is machine learning because anytime you say, "Well, serverless can do pretty much everything." Everybody's like, "No, no, I can't do machine learning." Which is true to some extent. So there are some use cases where machine learning does work. And then there are some that they don't, but I don't know, maybe you have some more insight into this.Gareth: Well, there's a few angles you can actually take on that because it all depends. I think one of the biggest Achilles heels of Lambda when it comes to machine learning is really Lambda's disk space that's available to you. Because a lot of the times with Lambda you need to import additional libraries in order to run machine learning models. You also need to import your models, which can often be enormous amounts of megabytes inside, yeah.And that means you've got some limited space to work with there. And if you can actually fit those libraries in those models onto a Lambda function that turn out 250 megs of limited space well then you could probably run that in parallel, like I mentioned the Lambda super-computing, you can run those in parallel and potentially get a lot of work out of Lambda functions. But serverless as an architectural concept isn't necessarily just about Lambda functions either.I mean the whole point of serverless is to look at the managed services that are available to you so you don't have to rebuild everything from scratch, remove that undifferentiated heavy lifting. So again, there's a couple of angles on this because if you want to build an image recognition model yourself, well, maybe reconsider that. Because there are image recognition models out there that you can use.If you're doing text to speech, well, there are text to speech engines already available in AWS, and they might be good enough to do what you need to do. Of course, if you're trying to build your own product that is a text to speech product, well, okay, I get it, then you might want to build it yourself. But if you find that the model you're doing isn't quite provided by these services. There's one additional service that you can use in a serverless context.And that's Fargate, which is pretty cool service to look at. It's different to Lambda in that it isn't quite as responsive. So if you're looking for something that's low latency and can really get things done really quickly, Fargate might not be the tool for you, but if you're doing ML models, that's probably not your concern. And Fargate's for anybody who isn't aware... Fargate is a service that lets you run Docker containers without worrying about any of the underlying orchestration and management of them.You essentially say, I need a Docker container. This is the image, this is the parameters of what I need to execute and Fargate will spin up that infrastructure for you in the background. I don't know how AWS does it. But again, that's the beauty of it. I don't need to. They manage all of that for you and you allocate the disk spaces as well. When you're building these images, you set up the disk space you need, you import the libraries you need, the models you need, and it'll just execute in AWS's backend. So that's a great way to run your own models. And another angle is SageMaker. So there's many ways to take this where AWS provides a service that lets you run them on models. SageMaker is a way...Jeremy: They have the models already built for you in most cases too.Gareth: Yeah. So you can just import your models and run them. And there's an entire set of infrastructure back there to let you run your machine learning models anywhere that you like.Jeremy: Yeah. I totally agree too. I mean, there's just so many options for doing that. And like you said, there's a ton of these media services that they have. They have Lex, they have you know, Rekognition with a K that allows you to do image recognition and some of those things. The sentiment analysis, I think it's Comprehend, right? And we've talked about that a little bit earlier. That's machine learning.That stuff is just there for you and it's just an API call away right from your Lambda function or whatever you're doing. And so unless you have some really unique machine learning model that you need to build. There are still options to do that in a fairly serverless way or close to serverless way, just maybe not on Lambda functions. But anyway, so listen, this has been a great conversation.I think hopefully people have learned a lot from it, but before I let you go, I do want to ask you. I mean, you do work with some customers at Serverless Inc. You sort of help them figure out how they want to move to serverless and what they're building. So what are you seeing as sort of those first steps that companies are taking as they're starting to migrate or think about serverless?Gareth: Yeah, it's interesting. One of the downsides I think of serverless is that, it is such a new way to build things that it initially seems a little daunting. So a lot of organizations, especially the older ones have come from the idea of having your own servers on premise, and now this new cloud thing has happened. So we need to move to the cloud and they can essentially take what they have on premise just lift it and shift it into the cloud. And things are good. Things are familiar, there are some slight tweaks here and there, but pretty much it's what we know.But just running in their person's data center and the lift and shift seems to work. Serverless mostly that isn't a lift and shift type operation. But there is some limited ways to do some lift and shifting. So an example of this is, if you're already running an Express backend for example, you can pretty much take your existing Express backend and fit it into Lambda. And we have a lot of customers who do do that. And if anybody who has used all of the available services in serverless and built their Lambda functions from scratch, this might seem like an odd way to do things, but it's actually a really nice way to quickly get into serverless.And see some of those benefits that you get with the automatic load balancing and the disaster recovery and the less maintenance and so on, lets you quickly get into that. And we see this across the board. There's even a project now, it's a project out there called Bref for example. If you're building PHP applications where you can just run your Laravel or Symfony application on Lambda functions for example.So we see that a lot as the initial use case, where folks want to take what they have existing and lift and shift it into serverless. And then ideally what we find is that they understand that there's limitations to this, because you're just taking what you already know and putting into something brand spanking new, and then you start realizing there's a lot of benefits to serverless that you're not really getting by doing that.So things like making full use of all of these services that are available to you in AWS because you can't necessarily get your Express backend to get triggered by an S3 bucket, for example. And Lambda function does that and it doesn't really speak to Express really cleanly. That's when we start helping organizations with those POCs where they're building a sort of cloud-native, serverless-first style application or just one small element of their application as a serverless-first item. And this runs the gamut.We have a conference coming up that's going to have thousands of attendees. We want to build a mobile application that's only going to exist for that weekend. Let's build it serverless and see how that works out. Or we have a review system on our site that customers, sort of reviews to this third party, but let's rebuild our integration into our frontend using serverless for example. There's so many different use cases on these POCs that folks are trying to do.And ultimately you find that we then end up in a situation where they realize that serverless is incredibly powerful. Their Express or their Django, or their Flask app is running really well. And their POC for the serverless-first application is running incredibly powerful and reliably. Now they start looking at re-architecting their entire stack a lot of the time using serverless as the primary way to do this.And again, it's very difficult to put a use case there because again, this runs the complete gamut from everything we've spoken about tonight, whether they're integrating WebSockets with parallel compute and Jamstack style applications and so on. And it's a really exciting field to be in because all of this growth in serverless that we're seeing and all these different use cases with organizations out there.Jeremy: Yeah, no, totally agree. I mean, that's just awesome. I mean, and that's what I love about sort of how serverless works, is that there are a lot of really easy on-ramps, right? I mean, the DevOps piece of it running some of those cron jobs and doing something that's peripheral to your application, or building out a separate microservice that does the reviews or does some sort of integration, or does your PDF generation or that kind of stuff. But it's not touching the main system.But then starting to build more complete tools, taking advantage of sort of that Lambda lift or that fat Lambda that does a lot of processing for now. But then start breaking it up, use the strangler pattern, start sending things to different services. Yeah that's just awesome. Thank you so much for doing this episode because this is one of those questions where people are like, "Well, what can you do with serverless?" And really it's what can't you do with serverless? And right now we're getting to a point where it's just really there are very few limitations here. Yeah, I just think it's amazing.Gareth: Yeah. I've had folks ask me, so what can't you do with serverless? And that actually, it's one of the most difficult questions for me to answer. In the past, it used to be that you can't run really long compute and then AWS increased the timeouts to 15 minutes. So then that removes a lot of use cases that you couldn't do anymore. And then they introduced Fargate, so if you'd really had something that you needed to run in the background for a very long period of time, now you can do that with serverless.So with just the whole industry and the whole architecture is advancing so rapidly and so many new services are coming out. AWS keeps listening... The other vendors too. We've been talking a lot about AWS. The field is growing enormously with other vendors too. Like Azure for example. And Google even making a lot of inroads in their serverless infrastructure that they're building outJeremy: Tencent is doing a lot.Gareth: Tencent is actually busy deploying a lot of cloud services right now. And in fact Serverless Framework, we have support for Tencent because they approached us and said, "Listen, we want to make sure we can do serverless, stuff because this is the way of the future." And that's what they're focused on now.Jeremy: Yeah. No, and I mean, that's I guess my last point would be just for people that are moving into serverless, trust the services in the cloud. Right? The cloud can do things better than you. So just moving your Express app over into a single Lambda function. Everything like retries and failure modes and some of those other things. There's so much stuff built into the cloud.So it's not you having to do all of it yourself. There's just a lot of support there. So anyways, Gareth thank you so much for being here. If listeners want to get a hold of you and read some of the great blog posts you have. How do they do that?Gareth: Well, most of my blog posts are written on the serverless.com websites. And that's easy to find serverless.com/blog. We pretty much update regularly about the serverless framework, new features we're bringing out. And then all the work we're doing at Serverless. For me personally, if anybody wants to get in touch personally, they can get ahold of me on Twitter, it's @garethmcc on Twitter. Nice and easy to find. And yeah, that's really the best way to get in touch with me and see what I've been writing.Jeremy: Awesome. All right. We will get all of that into the show notes. Thanks again.Gareth: Awesome. Thanks so much, Jeremy.THIS EPISODE IS SPONSORED BY: Datadog

37mins

27 Apr 2020

Episode artwork

Episode #45: Serverless Use Cases with Gareth McCumskey (Part 1)

Serverless Chats

About Gareth McCumskey:Gareth McCumskey is a web developer with over 15 years of experience working in different environments and with many different technologies including internal tools development, consumer focused web applications, high volume RESTful API's and integration platforms to communicate with many 10's of differing API's from SOAP web services to email-as-an-api pseudo-web services. Gareth is currently a Solutions Architect at Serverless Inc, where he helps serverless customers planning on building solutions using the Serverless framework as well as Developer advocacy for new developers discovering serverless application development. Twitter: @garethmcc LinkedIn: linkedin.com/in/garethmcc Portfolio: gareth.mccumskey.com Blog Posts: serverless.com/author/garethmccumskey/ Watch this episode on YouTube: https://youtu.be/Q3tbdlHH0MgTranscript:Jeremy: Hi everyone. I'm Jeremy Daly and you're listening to Serverless Chats. This week I'm chatting with Gareth McCumskey. Hey Gareth, thanks for joining me.Gareth: Thanks so much for having me Jeremy.Jeremy: So you are a solutions architect at Serverless Inc. So why don't you tell the listeners a little bit about your background and what you do as a Solutions Architect?Gareth: Sure. So, going back a bit, I mean I've been a web developer for a few years now coming up to 15 years. It doesn't feel quite as long as that, and I actually started back in the days of building a PHP web frameworks and so on. And my first start with serverless was back in 2016 where I actually, was taking over the lead of a team at the time.And part of my job there was to try and help modernize this aging WordPress monolith that had been the company's entire online presence at the time. And the company, they sold tours online. And online was the only way that they sold their product. So it was quite important to have this product working well. And then I was going through the usual steps, just taking a look at how we could potentially modernize things, looking at the Laravels and Symfonys of the time.And I was chatting to one of the guys at Parallax Consulting who had helped this company set everything up on AWS. Get all the VMs up and running in the load balances and so on. And one of them suggested that I take a look at the serverless thing that one of their team had spotted. So I thought, well, let me give it a try. Let me give it a... We see what this thing is.And that really ended up being my road down into serverless, because the moment I picked serverless up and started looking at potentially building a RESTful API out of serverless to help modernize the architecture for the company, that was me. I was down the road and started building a POC. And the POC we had was just to take one small portion of the existing stack and replace it with something completely based off of serverless.Something that received reasonably high traffic that wasn't super critical for the running of the organization. So if it failed, it wasn't a train smash. But if it succeeded, it would give us a great indicator that this was something we could definitely move forward with in the future. And ultimately the POC was a raging success.Everybody in the organization was incredibly impressed with how well this serverless tech that we built. And to be perfectly honest, it wasn't even the best architect serverless tech in the world, but it still performed incredibly well, which was quite impressive at the time. So yeah, we were really happy with that. That essentially solidified serverless for me and the way forward for me in the future.Jeremy: Awesome. And so then you started working at Serverless Inc as a solutions architect. So what are you doing there now?Gareth: So now I'm involved with the growth team and being a startup the roles are quite mixed, so I'm called a solutions architect. But I end up doing a lot of different things. One of my main roles is involved in support of our paid product. Serverless Framework Pro dashboard, I help users who are using our product and helping them deploy it and set things up. We have a number of users who need support and help and assistance in setting up their serverless architectures and designing those sort of architectures around their use cases.That's a really interesting job where you get to see quite a variety of ways that organizations are using the Serverless Framework. And it also means I'm working on content all the time, so I'm writing blog posts, producing videos, talking to the community, doing talks, all the usual sort of developer relations side of things as well. Keeps me quite busy.Jeremy: Awesome. All right. Well, so since you are so deep into this stuff now, and again, you're working with a bunch of different clients with Serverless Inc, you're writing these blog posts, you've been doing this for quite some time now. I mean, I think you started what? Around 2016 or so working on serverless. Is that about right?Gareth: Yeah, I started in 2016 building serverless applications for the first time, and last year I joined Serverless Inc themselves. Yeah.Jeremy: Right. So in terms of experience with serverless, you probably have the most amount of experience you can possibly get, right? Because this is such a new thing. So you've been doing it for a while, you've been seeing all these different things. And one of the things I think is really interesting for people to be able to see and especially people who are new to serverless is this idea of what are the use cases that you can solve with it. Right?And it's funny, if you're familiar with James Beswick, he has this sort of joke that he used to do it and in one of his presentations where he thought serverless was just for converting images to thumbnails. Like that was sort of like a very popular use case way back, when this first started to become a thing. And obviously you see a lot of things like web APIs and some of this other stuff.But I'd love to talk to you about that today. Because I think there are a broad range of serverless use cases. And I'm probably in the camp of you can basically do anything you want with serverless. There may be a few exceptions here and there. But maybe you can just give us a... What do you see as like the most popular serverless use case?Gareth: All right. Now by far the most popular use case is using serverless to build APIs. Whether that'd be a RESTful API or even a GraphQL API. And that's hands down the most common use case at the moment. And I think that was primarily pushed by the fact that API Gateway is actually such a great technology to use for building APIs, specifically RESTful APIs because it just takes away so much of that headache of trying to manage where web servers, load balancing them, a whole bunch of features that it includes to help you build your APIs, including things like JSON Schema requests Syntax, API keys that you can use to throttle users on your APIs and a bunch of others.I mean, it's an amazing technology and then you combine that with the power of something like Lambda in the backend that you can use to receive these requests, process them and glue all the other managed services that you may need like DynamoDBs and so on. And you have a very, very solid wrestle API backend that you can very easily use. And then when you combine that with something like the Jamstack, which is a relative... It's odd how this relatively new phenomenon that's coming out is essentially a regurgitation of an old phenomenon that we used to do in the old days.Where the static files are stored on a server and it's just serving HTML, CSS and JavaScript. And we have an API backend that helps us manage all the dynamic data that gets populated in aesthetic files now. It's become known as the Jamstack essentially. And that becomes a very popular use case for building web applications on serverless.Jeremy: Awesome. So let's dive into the HTTP or the API use case a little bit more because just so if people are listening to this, I'd love when we can kind of teach things on this podcast and we can get people to sort of just understand or make it click. Right? And so you talk about an API Gateway, we talk about Lambda as the backend. Maybe just explain exactly what you mean by, what is API Gateway and then how does Lambda really tie into that?Gareth: So API Gateway essentially is, AWS is a solution to give you endpoints. So you need some way to expose an HTTP endpoint to any client. And in this case, when I'm talking about Jamstack, I'm talking about a web client and a browser, but it doesn't necessarily just have to be a web browser either. It can be a mobile application. And that's another very common use case we see, where web APIs are reused in a mobile application to provide data to a web app client. And API Gateway is the front facing feature that allows you to receive data from your users.So if you think of a front end that's using React or Vue or any of these jobs for frameworks, it's going to send a request to the same point, be it a GET, POST, PUT, DELETE whatever it might be to help manage that data. And in that way, it's building, it's hydrating a UI off of this API Gateway backend that you built. And I think gateway is essentially a replacement for what you would normally traditionally knows as roots in your web framework.If you've used any of these MVC style web frameworks, you'd have a roots configuration that you'd apply, that would then point to a controller, potentially with some actions in them that then handles those requests. And API Gateway essentially removes all of that work for you. You just need to configure a path pointed at a specific Lambda function and your code then receives an event object from API Gateway that contains all the details you need for this request.Including everything from, your headers that have been received, a few added in by API Gateway to help you make some analysis on your request, potentially, to the body content that's being sent. If this is a post request, for example. So it's essentially it replicates the effect of having an HTTP request come through any old web server like an Apache or an Nginx. But without any of that concern about configuring this very complicated piece of technology on an EC2 instance that you could mis-configure which I've never done, I promise.Jeremy: Or not secure properly.Gareth: Yeah, exactly. So yeah, just combining those two really makes it incredibly powerful. Especially because when you look at Lambda. Lambda is an event driven way to run code. So Lambda by itself is kind of useful, but if you drop something like API Gateway in front of it that can trigger the Lambda function and pass data, you now have a match made in heaven essentially, something that could receive your data and then process it in real time.Jeremy: Right? And so, I mean, that's the thing that's powerful about Lambda, right? And so Lambda is this one part of serverless Lambda functions-as-a-service if people are familiar with that term. And that essentially allows you to run code, whatever it is. And like you said, in response to events. But API Gateway is one of those really cool tools. Right now, there's a new version of it or there's the REST APIs, which is the existing version.There's the HTTP APIs, which we talked about on the show a couple of weeks ago. But what's cool about the REST version, and this is something that will be coming to the other version as well, is this idea of service integrations, right? So Lambda functions are great and they can do all kinds of processing. But maybe explain, "Hey, maybe I don't want to use a Lambda function, maybe I don't need to use a Lambda function." What can you do with service integrations?Gareth: Well, one of the really interesting things is if you have a client application that's making API requests, sometimes you want that response from the actual request to come back really quickly to the client side, because you've set things up in your infrastructure in a way that you know the request is going to get processed eventually. And this is the idea of asynchronous processing. So you make the request, the AWS or API Gateway essentially comes back and sends 200 success, don't worry about it. We've got this now. And in the back, what you've done is you set up this integration with another service, like an SNS or an SQS or something like that, that receives that data from API Gateway.So instead of directly diving into a Lambda function, which becomes asynchronous request, this means your client then has to sit there and wait for the Lambda function to complete execution and return a success or a failure code. API gateway can immediately send us data into a service integration of some kind. And that data will eventually get processed, an optimistic style of coding your client, your frontend, and so on. It's a very, very, very useful and efficient way to handle your API requests, so you don't have to keep diving into Lambda.And then you also, you don't end up having the additional cost associated with the Lambda function. Because then the functions do build unit, for every 100 milliseconds of execution time. And in the past, if you had just been taking the event data from an API Gateway request and dropping it into SNS or SQS service anyway, well let's just saves you having to do that in the first place.Jeremy: Right? And a lot of those good use cases around something that you would use an HTTP endpoint for, that would be perfect for SQS or maybe Kinesis or something like that, would be like the webhook. Right? You know, you've got a lot of data coming in. You don't need to respond to the webhook with anything that says, I've done all the processing. You just need to say I've captured the data.So that's where I think you get a lot of really useful benefit out of using something like that asynchronous pattern. Like you said, storing that data, throwing it into SQS, responding to the client immediately and then worrying about processing that data later on down the line.Gareth: Well, this is one of those interesting situations where... It's one of those things that didn't click for me for a while, that you have this powerful asynchronous processing capability available to you in AWS. Because traditionally if you're building a web application, you receive a request, you process things synchronously, you put things in the database, you handle those things and you return a response. Maybe you'll drop something in a separate queue.But generally things are done synchronously. Whereas with AWS, you can run things completely asynchronously if you wish. You can drop things into SNS queues, EventBridge, all sorts of different services. And that means that in the background, things are processing while your latency sensitive applications on the frontend, for example, are complete and it gives a great user experience. So it's a very interesting way to build an architecture.Jeremy: Right? And another thing that you see that's becoming very popular and I think this probably started with the idea of building mobile applications and trying to minimize the amount of data that you're passing back and forth, is this idea of GraphQL. Right? And the benefit of GraphQL is the client can make those requests and they can just request the data that they need.So that way they're not over fetching data. But also they can combine multiple bits of data together so that they're not under-fetching data either and need to make multiple calls. So API Gateway is great. You can actually build a GraphQL server with Lambda and API Gateway if you wanted to, "server" in quotes. But there's actually a service for that called AppSync. So can you just explain sort of what that does?Gareth: Well, AppSync is a great tool to take away the headache of managing your own GraphQL server, which is no small feat. It can become quite a hairy situation to do that yourself. But AppSync essentially lets you tie all sorts of different resolvers to your GraphQL query. So you could link one portion of your GraphQL query to a Lambda function, which will then go off and do some interrogation. They'd be inspecting these three buckets build a data model and return that to your AppSync bottle.You might talk straight to a DynamoDB table and pull some data in that way. You may even just grab items right out of an S3 bucket as part of your GraphQL query. And again, this gives you the power of an asynchronous feature where you're not necessarily incurring that latency involved in running code all the time. AppSync is always available. And just like a lot of the other services, it's pay-per request so you don't have a VM or a container sitting idle at 2:00 AM in the morning when there's no customers.AppSync is really in waiting to receive a request and only bills when there's actual requests and only executes in your architecture with there's actual requests coming in which is pretty useful as well.Jeremy: Right? Yeah. And the thing that's nice about AppSync is that it is just massively scalable. The throughput on it is insane. I mean, the same thing with API Gateway where you might be setting up load balancers in the past, right? Even if you're using elastic load balancers or application load balancers, you still have to worry about what it's hitting underneath. And if you connect these things right with serverless, that AppSync or I should say that GraphQL use case or that HTTP API use case is just massively scalable and it's very great.So the other sort of, I guess common use case that we see is this idea of real time communication and AppSync has a way of doing sinking. It does offline sinking and some of that stuff, it's kind of built in. There's a whole new data store thing that they built, which is really cool. But I think a lot of people are more familiar with WebSockets. Right? So that's another thing we can do with serverless now.Gareth: Yeah. And I've actually worked with an organization to help build out a eCommerce product using serverless WebSockets and the biggest advantage that WebSockets gives you is maintaining those connections to clients. And that really becomes one of the trickier things to do if you have to manage a WebSocket set of infrastructure yourself. But with WebSockets in API Gateway essentially part of API Gateway V2, AWS calls it. You have WebSockets available to you.And the product that we ended up building was essentially a product counter on a frontend that as a user is sitting watching a screen, you just see a counter counting down as items are sold. And this is this was part of a larger Magenta backend again. So you have a data store storing the quantity of products in your warehouse and as items are sold, it's updating through a sequence of Kinesis dropping into DynamoDB table, which can then trigger your Lambda function again.So this is all part of that asynchronous side of the things that I was talking about. Again you have a WebSocket connection that's set up by a client when they connect to a page. So they do a product page. The website and connection is created to your WebSocket backend that you create through API Gateway for example. And in the background you have Kinesis receiving data, but items that are sold that are triggering, that have been installed in DynamoDB.That DynamoDB is using streams to trigger a Lambda function which can then go and look at the current existing active connections on their product page and send that data to the frontend. And the frontend then receives the data and can update the DOM with the actual value of products available. And WebSockets are great for that kind of use case because you're not dependent on a 100% perfect liability.WebSockets do have a reputation of not being perfectly reliable. But if you need to give people and a rough estimate of the amount of products available in a product page, it's a perfect use case. It just gives that kind of nice solid feedback to the user that they're somewhere useful that they want to potentially maybe they want to buy because they can see the product running out or whatever it might be.Jeremy: Right. Yeah. And obviously things like real time chats and anything where you want to be able to push data back and forth, multiplayer online games. I mean there's all kinds of crazy things you could do with WebSockets, but I think something that probably confuses a lot of people when they look at the WebSocket piece of things, from a serverless perspective anyways, is the fact that Lambda functions, if people are familiar with how they work, they are stateless, right?So a WebSocket creates a connection, a long polling connection in a sense, and keeps that connection open and remembers who it is that's connected to it. But you're not running a Lambda function in the background that just sitting there and waiting. So can you explain how, because it is through API Gateway, but how API Gateway handles those long-lived connections while still using a femoral compute with Lambda?Gareth: So WebSockets on API Gateway. So essentially API Gateway manages that long-lived connection somehow with the client. To be perfectly honest, I don't know the integral details of how AWS have configured this and personally I don't really care. It works. It does the job and that's the point of serverless as well. I don't want to have to worry about that undifferentiated heavy lifting of running a WebSocket service.They do that really well. But how this works from an implementation point of view if you're building it yourself is that you essentially configure your WebSocket connection almost exactly the same way as you do a regular RESTful API with the serverless framework for example. And when that user connects to the WebSocket connection through API Gateway. You can set a specific Lambda handler to be triggered on a connection event with a WebSocket.And this is useful because you can set your Lambda to receive these connection attempts. Which gives you a unique client ID and this is negotiated between the browser and API Gateway itself. So you don't have to worry about the details of it. You get essentially a UUID of that user's connection. And at that point you now have a unique reference if you do need to communicate back with them.But as you said Lambdas are stateless, so we can't just use a session token or anything like that. So one easy use for that is DynamoDB, which if anyone's not familiar with it, it's a fantastic key value data store, that is incredibly useful in the serverless context and because of its low latency and high throughput, DynamoDB is fantastic for storing these UUIDs. Essentially because the only thing you're storing is a UUID and potentially the location that the person connected from, so you have some way to refer back to where they've connected.And then on the other side of things, when you have data that you want to send. So again in my example, like I said, you have a user on a product page. As they load their product page in the backend, your JavaScript saying, all right, you're on the product page, create a WebSocket connection for this user to this API Gateway endpoint that you've already pre-configured. When you built your infrastructure, your architecture.And at that point either it sets up the connection, triggers your Lambda function that gets triggered on connect with the UUID and the location of the page the person's viewing. And you can just log that into DynamoDB as is. When you have a product information updates come along, you can see that a specific product has a stock level change, you know the location in your frontend where this product is viewed, what the page URL is, what the path is.So you can just query DynamoDB for all users that are on that specific page. And at that point you now have all the UUIDs you need to send an updated quantity. And at that point it's up to the client. Again, the client receives this data across the WebSocket connection on that end, and that's your JavaScript on the frontend that will update the DOM with the correct value. And it sounds really, really simple and is actually as simple as that.There's none of the concerns about the load again, because all of the infrastructure we've used behind the scenes is completely load balanced because of how AWS manages this for us. We're not dependent on any server-full infrastructure that might need load balancing that might run out of capacity because DynamoDB is an absolute a monster when it comes to providing you capacity.API Gateway itself, as we've said, has all the capacity you might need. And most of the work then is done by the client, which updates the DOM in real time when the data comes across the WebSocket connection.Jeremy: Right? Yeah. And I actually, one of the startups I was at, well, several years ago now, we built a real time interface. You could comment on things, comments would appear in real time. We started using long polling, right? This is constant polling, which is just a terrible, terrible idea. You'd always setting up and tearing down connections on. So we ended up installing the software, I think it was called Ape, A-P-E.I had to modify some of the backend because it wasn't a load balanced application. So we had to make it so that it would work from a load balance standpoint. And so we had multiple EC2 servers running. We had an elastic load balancer in front of it. And we had to bounce them back and forth between those. We had to use sticky sessions. It was a nightmare. And I don't know if anybody's ever tried to build a chat application at scale, but it is a lot. It is a lot.And so this WebSocket use case from API Gateway just... I mean I really like the way they set it up. I think it's really, really interesting. I do wish there was like a broadcast channel that you could use to maybe like broadcast to everybody that was in group A or group B, without having to run some of those things. But it is very possible and like you said, it's actually not too difficult to set up.Gareth: One of the interesting things is when I first started building back in 2016, we needed a WebSocket-style set up as well at that time. And back then, API Gateway didn't have the WebSocket capability built in. But there was, you'd jerry-rig it with a bit of, using the IoT service, in AWS and MQTT protocols and WebSocket connections and get it working. And that was one of those situations where we went down that rabbit hole, we bought all the stuff out, it looked really great. It performed really well. And as soon as we were done, WebSockets came out with API Gateway. So that's one of those lessons you learn in serverless that the moment you want to build something yourself AWS solves the problem for you.Jeremy: Well, what you need to do is you just need to pretend that you're building it and tell everybody you're building it and then AWS will come up with it a few months later. And then you don't actually have to build it. But, no that's...Gareth: Tweet it a couple of times. Block it a couple of times, let AWS know.Jeremy: Exactly. All right. So those are really great frontend use cases, I think. I mean the API Gateway obviously or the API use case you can use for internal APIs and some of that stuff as well. I think that makes a lot of sense. But there are a lot of other use cases that go beyond just maybe interacting with a website, and then this ties into this, but this could be used for other things as well, and this is this idea of clickstream data.Gareth: Yeah. So clickstream data is an interesting one because, a lot of the time, and we find ourselves, I was working with an organization who's finding that they wanted to get more information about what users of their product were doing. And this was more a case of they weren't personalizing. So again, this was an eCommerce platform and they wanted to provide some kind of personalization. Some personalized recommendations on the platform.And it was funny, tricky to do this because they weren't super high volume in sales. So it's difficult to pinpoint what the personalization would be, because they didn't have thousands of products that somebody would have bought and then understand what people like. So they wanted some way to determine if someone's viewing this, more often than not, they click through on this, they click on this, they select this, and this ended up with a project view sort of capturing clickstream style data.Clicking on a DOM element and sending that data to a backend to let process. And so there's a small element of frontend to this where you need to capture this data from your frontend, whether that's beyond your app or on a web frontend. And this is quite simply done with just some JavaScript that can record those click events and then eventually push those into a backend.And again, depending on your volume, and in this case the volume is reasonably high. You need a tool, you need something like a Kinesis for example, which is probably one of the least serverless serverless products that you very often find because Kinesis still has this element of you need to allocate shards or you need to allocate some form of capacity to it. But it still handles an enormous quantity of data which is pretty impressive.And it's really good at handling this time sensitive data that gets piped in constantly through a stream, exactly as the name suggests. And that's what we were finding. We needed some way to capture a lot of data very quickly and constantly all the time. So Kinesis is a great way to manage capturing this click stream data. But you also need somewhere to store this, once you're done.So Kinesis has a great feature called Firehose. It's actually called Kinesis Firehose, where you can capture all this clickstream data and just point at an S3 bucket and say, "Put all the data there." Instead of trying to find ways to process the data, once it's in Kinesis. And this prevents you from having to spend a lot of time and effort on Lambda or any other compute platform processing vast quantities of clickstream data, but you still want to capture this and store it somewhere.And then what this helps with is there are other services for example that you can use. I think services like Glue and Athena, two completely unrelated names that work together. AWS naming scheme hard at work. But Glue and Athena work really well together because Glue allows you to do things like introspect the format and the structure of your data, in a way that it can pass that to Athena as if it's a SQL table or SQL database. And lets you run SQL queries essentially on top of data just sitting in an S3 bucket which is incredibly useful.And that was eventually what ended up happening, was there was a personalization engine, in the background that was receiving all of this clickstream data that was being funneled into the AWS backend, dumped into an S3 bucket and then regular Glue and Athena jobs that were running, I think it was on an hourly basis. Even at that, I was triggered by a serverless Lambda.So you have these jobs rendering on a regular basis and with Athena running queries, you can now take useful information out of raw data and push that into any other BI platform you might have at that time, including a backend for the application itself to then start building personalization into the platform, which ended up being a pretty useful project at the time so.Jeremy: Yeah, no, and I think that the really nice thing about this Kinesis, to S3, to Athena, and you don't even necessarily need Glue. I mean, depending on how you're writing your data. Especially with Kinesis Data Firehose you can automatically convert it. You can actually run conversions while it's processing before it puts it into the S3 bucket. But what I really love about that is essentially is a 100% serverless and you're just really paying for when you run the queries, obviously you're paying for the shards and stuff like that for Kinesis.But you're not paying to just store this ton of data in an expensive storage place. I mean, S3 is relatively inexpensive for that amount of data. If you were to use something like Elasticsearch, which is a popular analytics tool and so forth. We tried that at one point and we were just doing some of the projections with the number of clicks we were collecting per day. And it would've just kept on adding more and more data, more and more data.We had to keep making the drives bigger and bigger and bigger in order to handle all this data. And we were thinking about, well, maybe aging some things out, doing some roll-ups, aggregations, and that's all possible. And you could still do that with S3 as well. But I really, really love that use case because, that is such an important thing now is capturing that data to understand what your users are doing on your site.And whether it's for personalization or whether it's for other types of optimization, or you're collecting clickstream data for AB testing or any of that sort of stuff. It is just a really, really good use case. And I think with the tools in place now serverless just handles it so well.Gareth: And the interesting thing is we actually... To start off with, we looked at two models and we went with the Kinesis model, but we even investigated using just API Gateway with a Lambda function, dropping items into S3 as one potential method to handle this. Just because that was what were familiar with at the time. And that works and the scale that you can get with that is pretty impressive.Kinesis just ends up being a more performant and a cheaper way to run these kinds of operations. But if API Gateway and Lambda is something you need as well, it can still handle these kinds of clickstream events. Just there are often specific tools made for a specific job, which is often a good one to go with.Jeremy: Right. All right. Again, clickstream sort of does fit into that frontend piece. But so as we move past this, one of the things that I know I've seen quite a bit of is people using just the power of Lambda compute, to do things right? And what's really cool about Lambda is Lambda has a single concurrency model, meaning that every time a Lambda function spins up, it will only handle a request from one user. If that request ends, it reuses warm containers and things like that.But, if you have a thousand concurrent users, it spins up a thousand concurrent containers. But you can use that not just to process requests from let's say frontend WebSocket or something like that. You can use that to actually run just parallel processing or parallel compute.Gareth: Yeah. This is one of what do they call it, the Lambda supercomputer.Jeremy: Right?Gareth: You can get an enormous amount of parallel... Try to say that three times quickly. Parallelization with Lambda...ON THE NEXT EPISODE, I CONTINUE MY CHAT WITH GARETH MCCUMSKEY...THIS EPISODE IS SPONSORED BY: AWS (Optimizing Lambda Performance for Your Serverless Applications)

35mins

20 Apr 2020

Episode artwork

JSJ 363: Practical JAMstack and Serverless with Gareth McCumskey

JavaScript Jabber

Sponsors Triplebyte offers a $1000 signing bonus Sentry use the code “devchat” for $100 credit Linode CacheFly Panel Charles Max Wood Aimee Knight AJ O’Neal Aaron Frost Joe EamesJoined by Special Guest: Gareth McCumskeySummaryGareth McCumskey introduces JAMstack and serverless. He goes into great detail on how it works. Aimee Knight and Aaron Frost voice their concerns about going serverless. Aimee thinks it feels dirty. Aaron has concerns about the code, is it actually easier, what use cases would he use it for, and does it actually save money. Gareth addresses these concerns and the rest of the panel considers the positive and negatives of using JAMstack and serverless. Charles Max Wood asks for specific use cases; Gareth supplies many uses cases and the benefits that each of these cases.Links http://herodev.com/ https://thinkster.io/ https://jamstack.org/ https://www.mongodb.com/cloud/stitch https://expatexplore.com/ https://serverless.com/ https://www.cloud66.com/ https://aws.amazon.com/dynamodb/ https://twitter.com/garethmcc https://www.facebook.com/javascriptjabber https://twitter.com/JSJabber PicksCharles Max Wood: Join the mailing list Watch out for new podcasts Send me defunct podcasts you love chuck@devchat.tv Aimee Knight: Productivity Isn’t About Time Management. It’s About Attention Management. Quest Nutrition Protein Bars AJ O’Neal: Distant Worlds: Music from Final Fantasy by Nobuo Uematsu Legend Of Zelda Concert 2018 Original Soundtrack by Never Land Orchestra How to Diagnose and Fix Everything Electronic by Michael Jay Geier Aaron Frost:The Go-Giver, Expanded Edition: A Little Story About a Powerful Business IdeaGareth McCumskey: https://www.finalfantasyxiv.com/ Steam Play on Linux Joe Eames: Expanding your horizons Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages Seven More Languages in Seven Weeks: Languages That Are Shaping the Future https://elm-lang.org/Special Guest: Gareth McCumskey.

1hr 10mins

7 May 2019

Loading