Django Rest Framework API #26 / How To Use THREADING To Improve API Performance.

  Рет қаралды 9,037

Code Environment

Code Environment

3 жыл бұрын

In this video you will learn:
- How To Use THREADING To Improve API Performance.
- How To send an email using Multithreading.
- How To Send an email using Gmail SMTP server.
- How To Configure settings.py of the API project to be allow email sending.
- Using send_mail from django.core.mail to send an email
Please if you have any questions, leave it in the comment below and I will be happy to help.
🎧 Music : • Study music | Programm...
Music Channel : @tuningthecode

Пікірлер: 24
@JustPython
@JustPython 8 ай бұрын
Very useful video
@mohdshoibsir4501
@mohdshoibsir4501 5 ай бұрын
Awesome tutorial. Thank You so much for this video.
@mrmuranga
@mrmuranga 3 жыл бұрын
informative.thanks
@manojsitapara
@manojsitapara 3 жыл бұрын
Very well explained !! Thank you. looking forward more video !!
@codeenvironment
@codeenvironment 3 жыл бұрын
Thank you for the feedback ✌🏻
@bibinkunjumon
@bibinkunjumon Жыл бұрын
Very well u explained
@prakashkumarbhanja6270
@prakashkumarbhanja6270 2 жыл бұрын
Nice concept and unique...😍
@ahmadta8303
@ahmadta8303 Жыл бұрын
Thank you, it was really helpful
@chetty1212
@chetty1212 6 ай бұрын
really appreciate this video about multi threading and a real world example . Is there more about this topic that u have ?
@codeenvironment
@codeenvironment 6 ай бұрын
Thanks Chetty!, unfortunately I haven’t released other content regarding this topic.
@zakchips
@zakchips 3 жыл бұрын
Thanks. Very useful approach as a "problem solving". I'll try to adjust method save() in my Post model which does a re-sizing van the uploaded images. I've noticed that it causes an obvious delay before it gets sent to AWS3 after it.
@codeenvironment
@codeenvironment 3 жыл бұрын
Thank you Tatiana, actually this is one of the use cases that I forgot to mention in the video, so ya definitely you should go for it 👌🏻
@curtwagner9705
@curtwagner9705 2 жыл бұрын
This way you're creating the thread each time you need to send emails. Wouldn't it be better to use and existing threadpool and just send it the task of executing the 'send mails' function?
@codeenvironment
@codeenvironment 2 жыл бұрын
Thanks Curt, it’s definitely something to consider
@Asgallu
@Asgallu Жыл бұрын
Great video!, is it the same as Celery?.
@codeenvironment
@codeenvironment Жыл бұрын
No it’s different.
@ololoshamedia4681
@ololoshamedia4681 Жыл бұрын
@@codeenvironment and why you are choosing the threading, not the celery?
@mehdi-vl5nn
@mehdi-vl5nn Жыл бұрын
zombie thread?
@yarik83men51
@yarik83men51 3 жыл бұрын
+++
@ALISHERpy
@ALISHERpy 2 ай бұрын
how can we get source of code
@codeenvironment
@codeenvironment 2 ай бұрын
Please check the description for the GitHub link.
@zakchips
@zakchips 3 жыл бұрын
These is my solution (attempt) for re-sizing user's uploaded images before sending them to aws. pastebin.com/GiqBmwDw Results: 1. without threading/multiproccessing = func img_work() executes in 1.3 sec for a file 900kB 2. with threading/multiproccessing = 0.05-0.00sec (same file) With this improvement it's still works very slow in event to proccess one image. I think it's more benefitial to bypass uploading user's files through my django instance directly the my cloud storage busket(AWS S3) and use there lambda function to re-size them. Unfortunately I haven't succeded in triggering lambda function. Will be grateful if somebody would give me an advice how to do it. p.s Does anybody have an experience in django-stdimage module?
@codeenvironment
@codeenvironment 3 жыл бұрын
That’s very useful information Tatjana, thanks for sharing. One thing I also experienced is that uploading images to AWS bucket using Django ORM is slow. Do you see the delay while uploading the images to AWS bucket?
@zakchips
@zakchips 3 жыл бұрын
@@codeenvironment My experience with dj(orm)+aws is quite limited. I'm mostly concentrated at user's interaction with my dj app: he can upload images and my dj app re-directs them (without) re-sizing to asw s3 bucket. Even this limited task looks more challenging that I had expected. As far I've done it in two ways: Option A = only boto3 1. in models.py: two related models where model Person Image with attr = person = FK(Person) and attr url = CF) 2. view.py creates an unique string for url and boto3 provides some func to send images to aws As a result my database PersonImage keeps info only about fk and url (unique string) linked to aws img. Advantages: more freedom. For example an ability to keep media folder inside dj app ( and store some uploaded images there instead of aws) Downsides: a.I can't find the way to re-size uploaded images in the view.py 2.less control in deleting images: if user decides to delete his image, he deletes only url (link to the image on aws) associated with the uploaded image. So I need to find the way how to delete real images from the s3 bucket. Option B = boto3 + django-storage Advantages: a. re-sizing of the uploaded img before sending to aws S3 is possible in method save() of the model Person. a. more control in deleting images: if user (or admin) deletes an uploaded image, real image on aws3 gets deleted as well. Down-side: a. more config in settings.py b. Upload images in dj app folder media isn't longer possible. Will be glad if other developers would share their ideas and experience in these issues. Thx.
Django Rest Framework API #30 / Improve API Response Using Hyperlinks
28:38
Heartwarming: Stranger Saves Puppy from Hot Car #shorts
00:22
Fabiosa Best Lifehacks
Рет қаралды 20 МЛН
ROCK PAPER SCISSOR! (55 MLN SUBS!) feat @PANDAGIRLOFFICIAL #shorts
00:31
Django async HTTP requests with asyncio and aiohttp
20:32
Very Academy
Рет қаралды 22 М.
FastAPI, Flask or Django - Which Should You Use?
9:49
Tech With Tim
Рет қаралды 52 М.
Django Rest Framework API #21 / Building Custom User Model
42:57
Code Environment
Рет қаралды 15 М.
Django REST framework: Concept behind different types of serializers?
55:40
How to Make 2500 HTTP Requests in 2 Seconds with Async & Await
4:27
John Watson Rooney
Рет қаралды 106 М.