How to Deploy FastAPI on AWS EC2: Quick and Easy Steps!

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ส.ค. 2024
  • In this video, I'll show you how to deploy a Python FastAPI application to an AWS EC2 instance, so that your API becomes publicly accessible on the internet.
    👉 Previous FastAPI Tutorial: • FastAPI Python Tutoria...
    👉 Code: github.com/pixegami/fastapi-t...
    👉 SSH to EC2 from Windows: stackoverflow.com/questions/5...
    👉 AWS: aws.amazon.com/
    👉 FastAPI: fastapi.tiangolo.com/
    👉 FastAPI on AWS Lambda: • Deploy FastAPI on AWS ...
    00:00 Introduction
    00:30 Launch an EC2 instance
    04:06 Connect to your EC2 instance
    05:35 Install pip and NGINX
    06:20 Route API traffic with NGINX
    09:06 Run the FastAPI server
    11:39 Testing the API
    13:01 Terminate the EC2 instance
    #fastapi #aws #pixegami
    🎨 Background vector created by GarryKillian
    www.freepik.com/vectors/backg...

ความคิดเห็น • 140

  • @pixegami
    @pixegami  2 ปีที่แล้ว +3

    💡If you want an even BETTER way to host your FastAPI, check out my video on how to use FastAPI with AWS Lambda: th-cam.com/video/RGIM4JfsSk0/w-d-xo.html
    This is serverless and in most cases is superior to EC2 in terms of scaling and cost.

  • @xplorewithpathy1407
    @xplorewithpathy1407 8 หลายเดือนก่อน +16

    for anyone wondering how to save and quit
    you'll first need to return to command mode. You can tell you're in insert mode if you see -INSERT- at the bottom of the editor. To exit insert mode and go back to command mode, press the Esc (Escape) key on your keyboard.
    Once you are in command mode, you can save and quit by typing :wq. This command is a combination of :w (which saves the file) and :q (which quits the editor).
    Press Enter after typing :wq to execute the command.

    • @faizanahmad3452
      @faizanahmad3452 8 หลายเดือนก่อน

      i just spend 1 hour on this :(😑

    • @oscarvgx
      @oscarvgx 4 หลายเดือนก่อน

      god bless you

  • @favs5286
    @favs5286 ปีที่แล้ว +5

    great content, i learned so much in under 15 minutes

  • @user-lm4gs6fc3p
    @user-lm4gs6fc3p 2 ปีที่แล้ว +1

    Thanks a lot! This is the only of thousands that realy helped me to launch my project!!!

    • @pixegami
      @pixegami  2 ปีที่แล้ว

      You're welcome!

  • @jithinjagadeesh4471
    @jithinjagadeesh4471 3 หลายเดือนก่อน +1

    Thank you so much for this video. Helped me a lot in configuring nginx and deploying on EC2!

    • @pixegami
      @pixegami  3 หลายเดือนก่อน +1

      Glad it was useful! I recommend checking out how to deploy FastAPI to AWS Lambda as well (it's cheaper and easier to maintain).

  • @kevon217
    @kevon217 7 หลายเดือนก่อน +1

    exactly what i was looking for. thanks!

    • @pixegami
      @pixegami  7 หลายเดือนก่อน

      Awesome! I'm glad to hear that :)

  • @arturoguillen90
    @arturoguillen90 2 ปีที่แล้ว +1

    Thanks brother, amazing job ...

  • @yannickpokam3864
    @yannickpokam3864 ปีที่แล้ว +1

    Thanks Bro !!! this video help me a lot,

  • @alexandere9723
    @alexandere9723 2 ปีที่แล้ว +2

    Great Video, thank you very much. Works like a charm

    • @pixegami
      @pixegami  ปีที่แล้ว

      Great to hear!

  • @HarshPanwar9524
    @HarshPanwar9524 18 วันที่ผ่านมา

    Amazing tutorial. Thankyou!

  • @shawn.builds
    @shawn.builds 8 หลายเดือนก่อน +1

    this worked for me. thank you very much sir!

    • @pixegami
      @pixegami  8 หลายเดือนก่อน

      Glad it helped

  • @berkefekeskin9172
    @berkefekeskin9172 ปีที่แล้ว +1

    Thanks for such a understandable tutorial.

    • @pixegami
      @pixegami  ปีที่แล้ว

      My pleasure. I hope it helped!

  • @smitimaheshwari5595
    @smitimaheshwari5595 ปีที่แล้ว +1

    Thanks a lot! This was really helpful. :)

    • @pixegami
      @pixegami  ปีที่แล้ว

      You're welcome!

  • @mapneto
    @mapneto ปีที่แล้ว +1

    thank you very very much! Greate Tutorial and explanation.

    • @pixegami
      @pixegami  ปีที่แล้ว

      Glad it was helpful!

  • @yloibx
    @yloibx 2 ปีที่แล้ว +1

    thanks. very useful.

  • @jspjsp30431
    @jspjsp30431 2 หลายเดือนก่อน

    thank's your kind video from south korea!

    • @justin23262
      @justin23262 2 หลายเดือนก่อน

      hi, can i ask? if I shutdown my computer, can people access my api ?

  • @mariaponomarenko3006
    @mariaponomarenko3006 ปีที่แล้ว +1

    You have such a nice voice 😍 THANK YOU FOR THE VIDEO

    • @pixegami
      @pixegami  ปีที่แล้ว

      Thank you, glad you enjoyed it! 🫶

  • @angelmata9607
    @angelmata9607 2 ปีที่แล้ว +1

    Thanks you very much it was very useful

    • @pixegami
      @pixegami  2 ปีที่แล้ว

      Glad to hear that!

  • @TheEricon
    @TheEricon ปีที่แล้ว +7

    would be nice to see you implement the https version of this, amazing video!

    • @pixegami
      @pixegami  ปีที่แล้ว

      Thanks for the suggestion!

    • @alberjumper
      @alberjumper ปีที่แล้ว

      @@pixegami Is it done now??

  • @joseramon1017
    @joseramon1017 2 ปีที่แล้ว +1

    whoa! This is awesome 🌟 🌟 🌟 🌟 🌟

    • @pixegami
      @pixegami  2 ปีที่แล้ว

      Thank you! Cheers!

  • @mil0rd78
    @mil0rd78 5 หลายเดือนก่อน +1

    Excelente tutorial, gracias por compartir tu conocimiento

    • @pixegami
      @pixegami  5 หลายเดือนก่อน

      You're welcome!

  • @abbasali6588
    @abbasali6588 ปีที่แล้ว +6

    Great video!!! You even cleared a lot of fundamentals for me! I believe the same concepts will work for any ubuntu vps right ? Other than an ec2 instance ?
    thanks!

    • @pixegami
      @pixegami  ปีที่แล้ว +2

      Yup, I think most of the concepts will still apply to any kind of Linux VPS :)

  • @SantiagoZuluaga
    @SantiagoZuluaga ปีที่แล้ว +2

    Great Video, using vim like a Crack!

  • @lamarkneris3367
    @lamarkneris3367 ปีที่แล้ว +1

    Thanks a lot!

    • @pixegami
      @pixegami  ปีที่แล้ว

      No worries!

  • @timo_b3
    @timo_b3 ปีที่แล้ว +1

    Thank you!

    • @pixegami
      @pixegami  ปีที่แล้ว

      You're welcome!

  • @hectorherreraespinola6399
    @hectorherreraespinola6399 ปีที่แล้ว

    HI! very good video. I have a questions. After stopped the virtual machine and restart it, the FastAPI app does not work. Should I change any information each time I turn off the created EC2?

  • @user-eg9dc8kz2d
    @user-eg9dc8kz2d 6 หลายเดือนก่อน +1

    thank you!

    • @pixegami
      @pixegami  5 หลายเดือนก่อน

      You're welcome!

  • @randomforest_dev
    @randomforest_dev 8 หลายเดือนก่อน +1

    I used to create a new domain config under 'sites-available' first and then link to 'sites-enabled' ? what is the right way?

  • @anggipermanaharianja6122
    @anggipermanaharianja6122 ปีที่แล้ว +1

    NICE

  • @avighnajha7114
    @avighnajha7114 2 ปีที่แล้ว +4

    Hey, great tutorial. Im currently working on my first API for an android app and was wondering how the api connects to a database once deployed to cloud? Does the database also need to be uploaded? Im sorry if the question sounds dumb but im still learning.

    • @pixegami
      @pixegami  ปีที่แล้ว +2

      Great question - That's the next step! If you host your FastAPI on EC2, you can just put the database on EC2 as well. But here I just released a video on how to host a serverless FastAPI (and use a serverless database with it): th-cam.com/video/iLt00bqp6is/w-d-xo.html

    • @isaquehg
      @isaquehg ปีที่แล้ว +1

      If you're using a NoSQL database like MongoDB it's easier, bacause it's already deployed, so you only need to use the connection URL string in the API and give the needed permissions

    • @aashishmanandhar5188
      @aashishmanandhar5188 ปีที่แล้ว

      @@isaquehg bad suggestion imo, choice of db completely depends on the use case of the project. NoSQL might or might not fit into the usecase.

  • @KTMedia-hx5gg
    @KTMedia-hx5gg 11 หลายเดือนก่อน

    I am having problem in nginx part, when I try to close vim there, it doesn't close directly, It says either write a command or press enter, and takes me back to the same interface where I can edit the file

  • @jaykay999
    @jaykay999 11 หลายเดือนก่อน +1

    by the way guys, if you connect directly using aws interface, and you struggle to save the vim file where he adds the proxy pass and stuff. here is chatgpt answer to do operations for the vim file :
    vim has a steeper learning curve but is very powerful:
    Start in 'normal' mode (where you can navigate and use commands, but not type text).
    To enter 'insert' mode (where you can type text): Press i
    To save: First return to 'normal' mode by pressing ESC, then type :w and press Enter
    To exit without saving: Press ESC then type :q! and press Enter
    To save and exit: Press ESC then type :wq and press Enter
    Copy (called 'yanking' in vim): In normal mode, move to the line you want to copy and press yy
    Paste (called 'putting' in vim): Move to where you want to paste and press p
    Delete a line: In normal mode, press dd

  • @divyagarh
    @divyagarh 5 หลายเดือนก่อน +1

    Thanks for the video. Could you also make an video about nginx, gunicorn, supervisor and having a frontend like vue?

    • @pixegami
      @pixegami  4 หลายเดือนก่อน

      Thanks for the recommendation. I haven't actually used that stack much so I doubt I'll be able to make a good video on it, but I'll add it to my list of things to learn.

  • @justmiroslav
    @justmiroslav 9 หลายเดือนก่อน +1

    How did you put the cursor on --INSERT-- in the nginx file to write :wq and close it?

    • @xplorewithpathy1407
      @xplorewithpathy1407 8 หลายเดือนก่อน +1

      you'll first need to return to command mode. You can tell you're in insert mode if you see -INSERT- at the bottom of the editor. To exit insert mode and go back to command mode, press the Esc (Escape) key on your keyboard.
      Once you are in command mode, you can save and quit by typing :wq. This command is a combination of :w (which saves the file) and :q (which quits the editor).
      Press Enter after typing :wq to execute the command.

  • @chetanpatel2282
    @chetanpatel2282 ปีที่แล้ว +1

    @pixegami What about production environment?
    You explained how to run it.
    How can you keep it running if you are hosting on ec2 for production use?

    • @pixegami
      @pixegami  ปีที่แล้ว

      For production, if you are building a new app, I recommend going serverless. It's much easier to maintain and keep running (you don't need to worry about scaling, patching, load balancing, security). Check out a similar video for how to deploy FastAPI on AWS Lambda here: th-cam.com/video/RGIM4JfsSk0/w-d-xo.html
      And if you wanna add a database: th-cam.com/video/iLt00bqp6is/w-d-xo.html

    • @chetanpatel2282
      @chetanpatel2282 ปีที่แล้ว +1

      You tutorial is excellent but I found this tutorial. It can be used for production
      th-cam.com/video/t2AXy2y61oE/w-d-xo.html
      Sharing this tutorial so that it will be helpful to others.
      I spent almost 8 hours finding this solution last weekend.
      Thanks for the tutorial and quick response.

    • @pixegami
      @pixegami  ปีที่แล้ว

      @@chetanpatel2282 thanks for sharing!

    • @josephajibodu2377
      @josephajibodu2377 ปีที่แล้ว +1

      You can use a process manager to keep it running. Just like it’s done in NodeJS.
      Something like pm2, systemd, or even supervisord
      The will keep the app running and even restart if it crashes.

  • @raidwair
    @raidwair 11 หลายเดือนก่อน +1

    No creo que hables español, pero te amo.

    • @pixegami
      @pixegami  10 หลายเดือนก่อน

      Thank you :)

  • @dariusboteand7722
    @dariusboteand7722 2 หลายเดือนก่อน

    I'm using vultr, installed nginx and configured as shown. It just doesn't work for me, no matter how I edit this, the url just says that page isn't working... any idea?

  • @ApartmentAngelsFireStarters
    @ApartmentAngelsFireStarters ปีที่แล้ว +1

    Hi, love this vid, could you do a deployment video for ec2 or lambda where you deploy to a windows device?

    • @pixegami
      @pixegami  ปีที่แล้ว

      Thanks! Although I'm not sure what you mean by deploying to a "Windows" device. Do you mean a EC2/Lambda that runs a Windows OS?

    • @ApartmentAngelsFireStarters
      @ApartmentAngelsFireStarters ปีที่แล้ว

      Nah tbh I just wanted a way to self host my app with a static ip for freez thought ec2 would help out but yeah its all but if there's a way you could possibly display how you could port forward a fastapi app to https that would be a pretty good video, I haven't seen anything like that and I would appreciate it if you made a tutorial showcasing how you'd do that

    • @pixegami
      @pixegami  ปีที่แล้ว

      @@ApartmentAngelsFireStarters EC2 will cost money after a year, and a static IP is hard for people to type and remember and it can change if you reboot the server. Also, setting up HTTPS means you have to manage your own certificate and expiry. You'll also have to figure out how to patch and update your host so it doesn't become vulnerable to new attacks.
      Managing all that is possible, but difficult. That's why if you want to deploy a new app, I recommend going serverless instead.
      Check out how to deploy FastAPI to AWS Lambda. It's free for 1 million requests per month, and comes with a free HTTPS API endpoint (better than a static IP).
      If you need to persist data, check out th-cam.com/video/iLt00bqp6is/w-d-xo.html

  • @mikecmw8492
    @mikecmw8492 ปีที่แล้ว +3

    It would be nice to see how to automate this. In this case you are manually typing a command. What would you use to automate a deployment to the EC2?

    • @pixegami
      @pixegami  11 หลายเดือนก่อน +2

      Good point. You'd have to set up a CICD workflow. I recommend GitHub actions. Here's a new video I just made on it: th-cam.com/video/9uMcN66mfwE/w-d-xo.html
      The video doesn't look at EC2 specifically (I prefer Lambda for compute), but the concept's pretty much the same.

  • @user-zb9bp1jt4k
    @user-zb9bp1jt4k 5 หลายเดือนก่อน

    Hey,
    Great content.
    I have a question, if we stop the ssh session, will the server still be accessible from internet i.e. will the services still work?

    • @pixegami
      @pixegami  5 หลายเดือนก่อน

      Yes, it should be because the FastAPI server will still be running on EC2. However, you can still have the server crash and not recover. So even though this lets you set it up quickly, there's still a lot of work to do to make it resilient.
      You can also check out my other video on how to host this on AWS Lambda instead, which takes away a huge amount of the server management work you need to do: th-cam.com/video/RGIM4JfsSk0/w-d-xo.html

    • @isthatkhensi
      @isthatkhensi 4 หลายเดือนก่อน

      @@pixegami Hi, thanks for the great tutorial. I followed the steps and everything is working. However once I quit running uvicorn on my local terminal, the server gives a 502 error. Could it be my instance settings causing this dependency issue?

  • @suman6327
    @suman6327 11 หลายเดือนก่อน +1

    Thanks for this tutorial. Am new to AWS / EC2. Would like to know why would one need NGINX here ? Can't we spin up Fast API container & then access it using EC2 Public IP ??

    • @pixegami
      @pixegami  11 หลายเดือนก่อน

      You probably can, but using NGINX as a reverse proxy is a very typical design pattern for this type of app just because of the control and security it provides. But if you have a lightweight use case and don't need all the extra stuff that NGINX helps with, yes I think you can just use FastAPI on a fixed port.

    • @suman6327
      @suman6327 11 หลายเดือนก่อน

      @@pixegami I tried with & without NGINX - both work fine. Thanks 👍

  • @peterkim9696
    @peterkim9696 ปีที่แล้ว +1

    What if you close your terminal in your local linux machine would your fastapi close as well on Amazon AWS?

    • @pixegami
      @pixegami  ปีที่แล้ว

      Yup, general closing the SSH connection will also terminate the process.
      unix.stackexchange.com/questions/422188/sshd-into-a-linux-aws-box-how-to-exit-out-of-terminal-without-closing-script-r
      To work around it, you have several options. The easiest one is just to run the script as a background task.
      askubuntu.com/questions/396654/how-to-run-a-python-program-in-the-background-even-after-closing-the-terminal
      But a better way is to run it as a Daemon or a service, so it starts up with the system, and also restarts if it crashes.

    • @peterkim9696
      @peterkim9696 ปีที่แล้ว +1

      @@pixegami I want to run it 24/7

  • @eRiicBelleT
    @eRiicBelleT 4 หลายเดือนก่อน

    Can i expose it bia https without a domain?

  • @overneos2728
    @overneos2728 8 หลายเดือนก่อน

    Hello,
    I've been wondering, is it possible to use a port different port 80 ? And if you've covered this topic in another video

    • @pixegami
      @pixegami  8 หลายเดือนก่อน

      You can set FastAPI's server itself to a different port, but port 80 is the standard protocol for HTTP so if you want users to be able to access this via HTTP it eventually does need to be routed through 80.

  • @user-hj8vb7xv6e
    @user-hj8vb7xv6e 4 หลายเดือนก่อน

    Please let me know how to solve 404 error. Nginx not found and Bad gateway error.
    Im getting 404 error if i try to run the instance after couple of days of deployment.

  • @user-vm7od6lq4p
    @user-vm7od6lq4p ปีที่แล้ว +1

    f***ing legend

  • @leonardorojasquevedo9342
    @leonardorojasquevedo9342 ปีที่แล้ว

    Hi good afternoon , one question, I closed the terminal CMD , the api no found why?, the instance do not start?

    • @pixegami
      @pixegami  ปีที่แล้ว

      Yeah... that could be the case. If you run the API directly in the terminal, then when you close it, it might also terminate the API. You might need to run it as a background process, or as a daemon (agent).

  • @woodyjo
    @woodyjo หลายเดือนก่อน

    thank you for your help but I have a question in my case when I try to do "sudo service nginx restart" or "sudo service nginx start"
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
    it shows me this error how can I figure it out?

    • @MrKB_SSJ2
      @MrKB_SSJ2 4 วันที่ผ่านมา

      syntax error in nginx

  • @satwikawasthi2002
    @satwikawasthi2002 ปีที่แล้ว +1

    I couldn't understand if we launched our instance then AWS charged us and if not then after how much time it start charging?

    • @pixegami
      @pixegami  ปีที่แล้ว

      As of 2023 (when I'm typing this) EC2 has a 1-year free tier for the micro instance type: aws.amazon.com/free/
      But if you use serverless hosting (Lambda) you can get something like 1 million free requests per month, which is much better in my opinion: th-cam.com/video/RGIM4JfsSk0/w-d-xo.html

  • @yura2110
    @yura2110 2 ปีที่แล้ว +2

    hey, how can you make the fast api /docs not visible from the users ?

    • @pixegami
      @pixegami  2 ปีที่แล้ว +1

      You should be able to turn it off like this: `FastAPI(docs_url=None)`.
      See this for more info: fastapi.tiangolo.com/tutorial/metadata/#docs-urls

    • @yura2110
      @yura2110 2 ปีที่แล้ว

      @@pixegami thank you !! have a great day

  • @FarhanAhmed1360
    @FarhanAhmed1360 ปีที่แล้ว +2

    when I close my aws terminal then my fastapi app gone anyway. how to keep running my fast api app even I close my terminal ?

    • @pixegami
      @pixegami  ปีที่แล้ว

      That's because the Fast API process also terminates when you disconnect from the shell. You have to run it in the background. NGINX should have a way to do that for you - but if it doesn't, then you can try other ways to run it in the background (or as a Daemon).
      I don't have a video on it yet, but maybe something like this from the command: stackoverflow.com/questions/44222883/run-a-shell-script-and-immediately-background-it-however-keep-the-ability-to-in
      Or there are some more options here: stackoverflow.com/questions/1603109/how-to-make-a-python-script-run-like-a-service-or-daemon-in-linux

  • @amarnathreddysurapureddy9111
    @amarnathreddysurapureddy9111 6 หลายเดือนก่อน +1

    Hi Sir, 1) I followed your tutorial and i run the smallest Application with ec2 and fast Api. 2) I created big application in that static, templates and model folders is there . How can i include in configuration of nginx.

    • @pixegami
      @pixegami  5 หลายเดือนก่อน +1

      Nice work! I don't actually use NGINX a lot myself, so I think you'll have to look on your own how to integrate that with your FastAPI server. For FastAPI my preferred way to deploy it is actually to use Lambda functions like in this video: th-cam.com/video/RGIM4JfsSk0/w-d-xo.html

    • @amarnathreddysurapureddy9111
      @amarnathreddysurapureddy9111 5 หลายเดือนก่อน

      I got it no need to mention anything. folder structure is important.@@pixegami

  • @edwardwong654
    @edwardwong654 9 หลายเดือนก่อน +2

    Nice example. Wouldn't it be easier to just use docker, and deploy it on container with k8's?

    • @pixegami
      @pixegami  8 หลายเดือนก่อน +1

      It might be, if you have experience with Docker and K8s already. Personally I think something like Lambda is better for APIs like this (I have a tutorial on that too). But I think having a basic EC2 example as a tutorial is the easiest to grasp (even if it's not the best way to build this long term).

    • @edwardwong654
      @edwardwong654 8 หลายเดือนก่อน +1

      @@pixegami Damn. I appreciate you replying. I am not worthy. :-) But thank you!

  • @reocode
    @reocode ปีที่แล้ว +1

    Might look unrelated, but...
    What's your firefox theme?

    • @pixegami
      @pixegami  ปีที่แล้ว

      I don't use any special theme, I think it was just one of the in-built ones suggested my Firefox when I upgraded/downloaded it.

  • @princemoronfolu
    @princemoronfolu 2 ปีที่แล้ว +1

    Now how do you secure this. Since this is just public facing. Is there any authorization process?

    • @pixegami
      @pixegami  2 ปีที่แล้ว

      That's an excellent question - actually I think I'll make a video on the topic of authentication next to cover it.
      But to specifically answer your question, the API itself will need some sort of auth capability. Anyone can hit the endpoint with a request, but a request must be 'authentic' to be processed (and bad requests rejected with a 401 or 403 error).

    • @pixegami
      @pixegami  2 ปีที่แล้ว

      For FastAPI (and serverless APIs specifically) the popular way to do it these days is by using JWT tokens.
      This means the requester must seen a signed token that proves they are authenticated, and authorized to use the API. The token can only be signed by the auth provider (such as Firebase, Auth0, Clerk, and more), but it can be validated by the anyone who has access to the public key (which your API will).
      Typically, the token is sent in the HTTP request header under "Authorization". FastAPI has support to deal with this: fastapi.tiangolo.com/features/?h=authentication#security-and-authentication

    • @pixegami
      @pixegami  2 ปีที่แล้ว

      Finally, to prevent an attacker from obtaining a token and re-using it to use the API on a victim's behalf, tokens are usually short-lived (they have an expiry time after a few hours).
      But to get access to a victim's token, the attacker would usually need to have access to the victim's local environment to begin with (e.g. a public computer in a LAN cafe that didn't get logged out).

    • @princemoronfolu
      @princemoronfolu 2 ปีที่แล้ว +1

      Thank you very much for your answer also how do i achieve persistence with my database model. My dat that has been pushed seems to be wiped out after a while

    • @pixegami
      @pixegami  2 ปีที่แล้ว

      @@princemoronfolu If you're using Lambda, that's expected because the function is 'created' clean at the start of most invocations. If you're using EC2, then files and things you create should persist, so I'd be surprised if something is wiping it out - maybe there's a script or something that resets it? I don't know.
      But in either case, you *shouldn't* really be storing your DB model in your compute environment anyways. It is unsafe, difficult to back up, and will not scale. You need a separate service to host your DB, and your compute (whether EC2 or Lambda) and talk to it with API calls. That's the best way to build it.

  • @priyanshudeshmukh2431
    @priyanshudeshmukh2431 ปีที่แล้ว

    Why doesn't ec2 download tensorflow

  • @cyberpunk6654
    @cyberpunk6654 ปีที่แล้ว

    how to make it work over https???????

  • @akhilsharma392
    @akhilsharma392 2 หลายเดือนก่อน +1

    which is better for api deployment ec2 or aws lambda

    • @justin23262
      @justin23262 2 หลายเดือนก่อน +1

      hi, can i ask? if i shutdown my computer, can people access my api ?

    • @akhilsharma392
      @akhilsharma392 2 หลายเดือนก่อน

      @@justin23262 if its on local host then no
      If you host it somewhere then yes

    • @akhilsharma392
      @akhilsharma392 2 หลายเดือนก่อน

      @@justin23262 look if you hosted it somewhere and make outpost settings for everywhere then yes anyone can access

    • @pixegami
      @pixegami  หลายเดือนก่อน

      Personally, I'd go with Lambda. Better scaling, better availability, less maintenance.

    • @akhilsharma392
      @akhilsharma392 หลายเดือนก่อน

      @@pixegami yep I consider lambda also btw I am fresher working with cloud new to me and Thanks for comments it gives me a support

  • @nizor_
    @nizor_ 2 ปีที่แล้ว +4

    how do i keep fastAPI app running in production?

    • @pixegami
      @pixegami  2 ปีที่แล้ว +2

      Good question. If you follow this AWS EC2 tutorial, you will have a server up very quickly - but it is quite fragile. It doesn't have mechanisms to handle traffic surge, outages, reboots, or host/software patching.
      If you wanna continue using EC2, you need to add something like a health check and a boot script so that the server restarts when it fails. You might want to put it into auto-scaling group and maybe behind a load-balancer.
      But if this sounds complicated - then the good news is that there is also a better solution. We can instead deploy FastAPI to something serverless, like AWS Lambda (or AWS Fargate) instead. That will ensure that it is live, scalable and production ready all the time. I'll do a video on that next if people are interested!

    • @yangwang9688
      @yangwang9688 2 ปีที่แล้ว +1

      @@pixegami I’ll be looking forward to seeing the tutorial on Lambda

    • @pixegami
      @pixegami  2 ปีที่แล้ว +2

      @Yang Wang Here's the video with FastAPI on AWS Lambda: th-cam.com/video/RGIM4JfsSk0/w-d-xo.html Enjoy!👍

    • @yangwang9688
      @yangwang9688 2 ปีที่แล้ว

      @@pixegami I’ve watched the video, this is superb 🤩

    • @moayadalkhozayem4742
      @moayadalkhozayem4742 11 หลายเดือนก่อน

      you should've just mentioned that from the beginning smh...@@pixegami

  • @juliocesarpereirarocha3976
    @juliocesarpereirarocha3976 4 หลายเดือนก่อน

    I used this but give a 404 error in all situations

  • @steeeif
    @steeeif 2 หลายเดือนก่อน +1

    This videos shows how to test the app but it wont work due to server will be terminated once window is closed..

    • @pixegami
      @pixegami  2 หลายเดือนก่อน

      You can run the command with `&` at the end (on any Unix based terminal) and that should prevent the terminal from shutting down the process when it exits. They can continue to run in the background.
      But yes, if you want to go to production with this you'll need to quite a bit more work.

  • @dariusboteand7722
    @dariusboteand7722 2 หลายเดือนก่อน +1

    you missed the step for nginx where you show how to allow connection from firewall..... no wonder it didn't work for me first time I followed your tutorial

    • @pixegami
      @pixegami  2 หลายเดือนก่อน

      Hmm interesting, I must have missed that. Thanks for sharing your discovery!

  • @vamsyrraju
    @vamsyrraju 10 หลายเดือนก่อน

    how about https?

    • @pixegami
      @pixegami  10 หลายเดือนก่อน

      Hmm, it's pretty complex if you haven't done it before. You need to get a certificate for your app (from where like "LetsEncrypt"), maybe put a NGINX rule (or maybe FastAPI has native HTTPS integration, I'm not sure).
      Then you'd have to modify the EC2 instance and security groups to allow HTTPS traffic: docs.aws.amazon.com/cloudhsm/latest/userguide/ssl-offload-enable-traffic-and-verify-certificate.html
      Personally, I don't like to manage any of that stuff myself so I prefer to use something like AWS Lambda for my APIs, then use AWS ApiGateway to manage the endpoint (and configure HTTPS through it instead).

  • @panosp5711
    @panosp5711 2 ปีที่แล้ว +1

    My friend please highlight that you use python3.8 otherwise with python 3.10 you have to install 3.10

    • @pixegami
      @pixegami  2 ปีที่แล้ว +1

      Thanks for catching that!