How I generated 10,000 PDFs in seconds using SST

Поділитися
Вставка
  • Опубліковано 20 січ 2025

КОМЕНТАРІ • 68

  • @akashjohirul9409
    @akashjohirul9409 Рік тому +2

    this is just what i was looking for 2months ago, thanks for these kind of videos very few provide these kind of videos where most of them are only showing basic of the systems

  • @thesobercoder
    @thesobercoder Рік тому +3

    I've started to like SST a lot, too! Love your SST content. Keep 'em coming.

  • @tikeyike
    @tikeyike Рік тому +30

    It would be cool to see how you go through the process of creating a PDF template, using something like an invoice or a receipt page, where you use things like mustache or handlebars for templating etc. I know there are some libraries out there like reactPDF and things like tailwindPDF. I'm curious to see how you would approach something like that. I haven't really seen any good videos around this topic.

  • @joeyywill1234
    @joeyywill1234 Рік тому

    Great video again dude! Really enjoying these type of vids :)

  • @parlor3115
    @parlor3115 Рік тому +1

    Thank you so much for this. Your PDF videos are a god send!

  • @yousafwazir3167
    @yousafwazir3167 Рік тому +5

    Love this real world work

  • @butwhothehellknows
    @butwhothehellknows Рік тому +1

    Nice job love! 👑

  • @rustystrings0908
    @rustystrings0908 Рік тому

    Great solution. I use this exact same setup for a similar task, but to update all my lambda functions. I create a JSON file of all the functions I need to update, then using Lambda, push them into queues to update env vars, save a version, update the alias, etc.

  • @system_3147
    @system_3147 Рік тому +2

    Nice I got this to work. I went with the event bus instead of the SQS queue, it fires a single ID to the api which triggers an event to start and immediately replies 200. You came in really clutch with this video because I have made PDF using python on a running server but using puppeteer in a server less mode is really great because my new project is full server-less. THANKS!

    • @WebDevCody
      @WebDevCody  Рік тому

      I’ve never used event bus, I need to read about iy

  • @EduardLepner
    @EduardLepner Рік тому +2

    Interesting video, but the "spiciest" part is missing. Fanning out is trivial, how do you fan in afterwards and signal that the job is over? The latter requirement introduces state that one needs to handle and managing state is always PITA. We had similar stuff with PDF recently, same mess with puppeteer. In our case Azure Durable Functions was a pleasure to work with. I'm sure Amazon has same capabilities.

    • @WebDevCody
      @WebDevCody  Рік тому +2

      Aws has step functions. You can also just set a number to 10,000 in a data store and decrement that strongly consistent number and when it hits zero invoke your final fan in function

  • @peterakinlolu5993
    @peterakinlolu5993 2 місяці тому

    Thanks for this; do you have this set up in.a repo on github? I couldn't find the pdf repo

  • @nicolaasgrobler
    @nicolaasgrobler Рік тому

    Keep up the great videos!

  • @juanvieira8249
    @juanvieira8249 Рік тому +1

    Great video!
    I'm going through a similar path. I'm currently using sam-cli and it's alright for most use cases, but I found a blocker and thought SST could help.
    I'm now trying to define in SST quite a similar flow you have in this video: customer -> lambda -> sqs -> lambda -> external API
    My problem is I can't figure out how to link the pusher lambda to an existing ALB and VPC. I want the lambda to be linked and add a route in the ALB the rest of services are integrated in already.
    Any idea on how to define an ALB on SST?
    Thank you!

  • @ComfyCosi
    @ComfyCosi Рік тому +1

    I noticed you were using chunk([], 10) in order to limit the number of messages in the queue to 10, and therefore limiting lambda invocations to 10, is there another way of doing this? Is there like a lambda invocation maximum you can set perhaps using SST config?

    • @WebDevCody
      @WebDevCody  Рік тому +1

      SendBatchCommand can only accept 10 entries at a time, so you need to batch them

    • @ComfyCosi
      @ComfyCosi Рік тому

      @@WebDevCody Oh ok, so how exactly are you limiting the lambdas to 10 at a time?

    • @WebDevCody
      @WebDevCody  Рік тому

      @@ComfyCosi when you setup a sqs consumer you can specify how many events it’ll read from the queue at the same time. I think it defaults to 10

  • @slahomar1497
    @slahomar1497 Рік тому

    sir, do you recommend any course for learning what market needs when it comes to AWS ? ec2, s3, etc..

  • @artyte_b
    @artyte_b 9 місяців тому

    What is that rest client extension?

  • @huge_letters
    @huge_letters Рік тому +1

    What's the reason for using SQS to batch these pdf request events? Why not just do 10000 requests in your lambda 1(api) to lambda 2(pdf generator) directly?

    • @WebDevCody
      @WebDevCody  Рік тому +4

      Sqs has built in retry’s and error handling. If for whatever reason a pdf fails to generate for one of those events, the event will be pushed back into the queue automatically and retried multiple times until it’s successful. So for example, if s3 is having issues causing the pdf lambda to fail, or if the lambda runs out of memory due to generating a certain pdf, it’ll be retried. You can also setup a dead letter queue so that if the event fails X amount of times it gets placed in another queue you can use to further process or inspect. Btw, I do think if you invoke a lambda directly from another lambda using the async invoke sdk method, aws uses sqs behind the scenes

    • @huge_letters
      @huge_letters Рік тому

      @@WebDevCody cool!

    • @tradelyfewbphil2119
      @tradelyfewbphil2119 Рік тому

      Correct me if I'm wrong here, but Lambda limits 1,000 concurrent in flight requests per region at which the additional requests will be throttled. Just thinking this through, since there's a headless chrome browser opening and closing then the throttling could affect the run time more drastically than batching the requests using the queue. Would be interesting for you to test and bring the results to us @Huge Letters :)

  • @CalvinChang-z3e
    @CalvinChang-z3e Рік тому

    I am still tuing my dequeue lambda and queue, how much memory / timeout / queue batchSize?

  • @DC-yw5yg
    @DC-yw5yg 10 місяців тому +1

    lashonta

  • @Gabriel-ms6qw
    @Gabriel-ms6qw Рік тому +1

    Can you do a video about caching data? (like jsons etc) using Redis vs Memcached, with aws (sst). So basically let's say you are airbnb and you want to cache your listings on the landing page so the users don't hit the database every time

    • @WebDevCody
      @WebDevCody  Рік тому

      I have a video about caching using redis. Published it a few weeks ago

  • @Selient
    @Selient Рік тому

    how do you manage templates? I have the HTML code in my dequeue lambda but that's kinda messy when I have 20+ more templates.
    (pdf content = input data + template)

    • @WebDevCody
      @WebDevCody  Рік тому +1

      we have a bunch of react .jsx template which we compile to html and send to puppeteer

  • @reastyn
    @reastyn Рік тому +1

    Hey, cool tutorial, you could speed up the processing times by not using await inside the for loop as you are essentially doing it synchronously which takes time. Instead use map and Promise.all the result. Probably will get you a big speedup

    • @WebDevCody
      @WebDevCody  Рік тому +1

      Oh in the api where I send off sqs events? Yeah that would speed stuff up assuming I don’t hit sqs rate limits or anything

    • @reastyn
      @reastyn Рік тому

      @@WebDevCody exactly, it's not as important I just wanted to mention it. Thanks a lot for these, SST seems like a really cool way of defining infrastructure in one language and codebase

  • @santoshgurung179
    @santoshgurung179 Рік тому

    Thank you 🙏!

  • @Magns-AI-m
    @Magns-AI-m Рік тому +1

    Why are you using puppeteer I can’t understand that?

    • @WebDevCody
      @WebDevCody  Рік тому +1

      Puppeteer can be used to take html and convert to a pdf. This allows us to write our pdfs using react and css which is easier than any existing pdf library I know of

  • @mishikookropiridze
    @mishikookropiridze Рік тому

    Can you use SST but provide lambda handles in different language ? to only replace aws cdk with SST

    • @WebDevCody
      @WebDevCody  Рік тому +1

      not sure, I haven't tried, but I assume you could potentially change the runtime to use go or something?

  • @1879heikkisorsa
    @1879heikkisorsa Рік тому

    Two things: why are you calling your api function file "lambda" considering you named the other lambda function more descriptive "generator"? Is there something similar to SST for GCP?

    • @WebDevCody
      @WebDevCody  Рік тому

      I don’t remember, probably just lazy

  • @grandpaK420
    @grandpaK420 Рік тому

    What is the name of the file icons extension?

  • @JosephDeMatteo-t9i
    @JosephDeMatteo-t9i Рік тому +12

    You should start a series off of this video where you try to do performance enhancements to it, trying to make it faster or ways of optimizing and such, I think that would be fun, maybe even try it in different languages.

  • @paulmesaric5059
    @paulmesaric5059 Рік тому

    How much did that cost? from an AWS billing perspective?

    • @WebDevCody
      @WebDevCody  Рік тому

      my billing dashboard says $0.17 for yesterday, and I ran this scenario twice.

  • @ted_marozzi
    @ted_marozzi Рік тому

    Why not just do it concurrently in one process (lambda or fargate container)? Is it memory constraints? I feel like Rust could crush this speed.

    • @WebDevCody
      @WebDevCody  Рік тому +1

      Puppeteer and chromium is what is used under the hood to generate these pdfs, not JavaScript or rust, so ultimately your bottleneck will be how many chrome tabs can you have open at once generating pdfs, and if chromium crashes, do you have enough error handling to reprocess all the failed processes?

    • @ted_marozzi
      @ted_marozzi Рік тому

      @@WebDevCody Would be interesting to test what these limits are, maybe a fun video idea?

  • @suleman_tariq
    @suleman_tariq Рік тому +1

    Please could you make a video about how to do all this stuff without using sst, meaning create lambdas and sqs manually on aws and then link them and then call them etc like a general thing so even those who're not using sst can take advantage of this setup. Anyway thanks for this, these kinda video that show real life implementations really help alot. keep it up.

  • @johnwildelgado8728
    @johnwildelgado8728 Рік тому

    Do u have a repo for this?

    • @WebDevCody
      @WebDevCody  Рік тому +1

      I think I lost the code, I’ll try to look for it.

  • @dyto2287
    @dyto2287 Рік тому

    Or you could just generate PDFs at client side and save cost on resources.

    • @WebDevCody
      @WebDevCody  Рік тому

      sure, assuming your users don't have a shitty mobile phone

  • @diemantrabeats7551
    @diemantrabeats7551 Рік тому

    Very very cool… as someone that doesn’t know much about aws, should I learn more about the core of aws before trying sst

    • @WebDevCody
      @WebDevCody  Рік тому +1

      Yeah you probably need to understand what lambda is at the very least, probably also api gateway

  • @AveN7ers
    @AveN7ers Рік тому

    Babe, are you planning to learn the next-gen frameworks like SvelteKit and Solid-Start?

    • @WebDevCody
      @WebDevCody  Рік тому +1

      nah I'm sticking to next. I'm not too interested in switching to use something new just to render a form to a page

  • @XEQUTE
    @XEQUTE Рік тому

    Slim shady lurkin

  • @delavalom
    @delavalom Рік тому

    I've never seen an easier setup using AWS

  • @marcin___
    @marcin___ Рік тому

    SST looks great at first glance, but if you try to build a real-world application with a few services it's almost impossible to connect all things together in a normal way. It's good for pet projects but nothing more. They also have the worst documentation ever, a few basic examples and that's it. I try to build a simple next app with graphql (appsync) + dynamodb + ses for emails - the worst 9 days of my life. Im switching back to Amplify.

    • @WebDevCody
      @WebDevCody  Рік тому

      It is a bit lower level than amplify, and yes the onboarding could be a bit better. Maybe more tutorials videos could help it a bit

    • @marcin___
      @marcin___ Рік тому

      @@WebDevCody Tutorials videos would be perfect. Also, give it a challenge, and try to build next app using SSG consuming graphql Api and maybe add some auth on top of it :D I'm really curious about your option about DX. Have a good one!

  • @lacherolachero9409
    @lacherolachero9409 Рік тому +1

    Great video thanks!!!! this helps me a lot
    btw, how did you understand `chromium.setGraphicsMode = false;`
    haven't find anywhere online where it says you need this in order the lambda function to work
    without this line I was getting timeouts on my lambda 🤯

    • @WebDevCody
      @WebDevCody  Рік тому +1

      It’s a bug. Without it the close method just hangs. There are open git issues that talk about it. All of this code makes me concerned honestly, but idk how else to easily run puppeteer inside lambda without using this Spartacus package 😂