Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Manejo de archivos grandes con una Django app &...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Emiliano Martin
August 13, 2020
Programming
27
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Manejo de archivos grandes con una Django app & DRF
Emiliano Martin
August 13, 2020
Other Decks in Programming
See All in Programming
AWSに止められる覚悟してますか?
morizo_1984
2
540
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2.3k
phperだってパンチカードでコーディングしたい
o0h
PRO
0
340
The Rails Doctrine Decade
koic
2
590
最近”作らせてる” ローカルAIアプリの話
akit37
0
480
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
610
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
280
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
190
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
120
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
350
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
330
Leo the Paperboy
mayatellez
10
2.4k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
560
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
520
Optimizing for Happiness
mojombo
378
71k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
630
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
The Language of Interfaces
destraynor
162
27k
Un-Boring Meetings
codingconduct
0
460
Designing for Timeless Needs
cassininazir
1
530
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
Transcript
Manejo de archivos grandes con una Django app & DRF
Agosto 2020 Emiliano Martín Software Engineer
Sobre mí ❖ Argentino. ❖ Esposo y padre. ❖ Ingeniero
en Sistemas de Información. ❖ Software Engineer en Mercadolibre +5 años. ❖ Apasionado del desarrollo de software.
Agenda • Problemática • Diferentes approach REST • Caso de
uso • Configurando nuestra app en producción ◦ Storage ◦ Uploaded Files and Upload Handlers ◦ Fine tuning Ngnix & uWsgi.
Large-scale Operations Data-science a escala: https://www.youtube.com/watch?v=Wgdy57Qn2rM
Problemática ¿Cómo enviar un modelo con su metadata usando una
API REST?
Diferentes approach REST ❏ Datos y archivo en un mismo
request (Multipart) ❏ Datos y archivo en diferentes requests ❏ Datos y archivo en un mismo request (Multipart + JSON)
class Message(models.Model): description = models.TextField() active = models.BooleanField(default=False) attachment =
models.FileField(upload_to="/tmp/") Datos y archivo en un mismo request class MessageSerializer(serializers.ModelSerializer): class Meta: model = Message fields = ["description", "active", "picture"]
Datos y archivo en un mismo request class MessageView(generics.CreateAPIView): parser_classes
= [parsers.MultiPartParser] serializer_class = MessageSerializer def create(self, request, *args, **kwargs): serializer = self.getserializer(data=request.data) # request.data[“attachment”] serializer.is_valid(raise_exception=True) serializer.save() return response.Response( serializer.data, status=status.HTTP_201_CREATED )
Configurando nuestra app en producción Imagen: http:/ /blog.ditullio.fr/2016/07/24/docker-django-uwsgi-nginx-web-app/
Configurando nuestra app en producción - storage
Configurando nuestra app en producción - storage
Configurando tu propio storage class Message(models.Model): description = models.TextField() active
= models.BooleanField(default=False) attachment = models.FileField( storage=MyStorage(), upload_to="/tmp/" ) • https:/ /docs.djangoproject.com/en/3.0/ref/settings/#default-file-storage
Configurando tu propio storage • _open() • _save() • delete()
• exists() • listdir() • size() • url() • https:/ /docs.djangoproject.com/en/3.1/howto/custom-file-storage/ • https:/ /django-storages.readthedocs.io/en/latest/index.html
Configurando tu propio storage - buffers
Revisando nuestra view class MessageView(generics.CreateAPIView): parser_classes = [parsers.MultiPartParser] serializer_class =
MessageSerializer def create(self, request, *args, **kwargs): serializer = self.getserializer(data=request.data) # request.data[“attachment”] serializer.is_valid(raise_exception=True) serializer.save() return response.Response( serializer.data, status=status.HTTP_201_CREATED )
Uploaded Files and Upload Handlers ❏ TemporaryUploadedFile -> TemporaryFileUploadHandler ❏
InMemoryUploadedFile -> MemoryFileUploadHandler • https:/ /docs.djangoproject.com/en/3.0/ref/settings/#std:setting-FILE_UPLOAD_MAX_MEMORY_SIZE • https:/ /docs.djangoproject.com/en/3.0/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS • https:/ /docs.djangoproject.com/en/3.1/ref/files/uploads/#writing-custom-upload-handlers ➔ FILE_UPLOAD_MAX_MEMORY_SIZE ◆ Default: 2621440 (i.e. 2.5 MB). ➔ FILE_UPLOAD_HANDLER ◆ Default: [ 'django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler', ]
Configurando servidores
Configurando Nginx client_max_body_size 7000m; proxy_connect_timeout 1200s; proxy_send_timeout 1200s; proxy_read_timeout 1200s;
Configurando servidor de aplicaciones • uWSGI ◦ uwsgi.ini post-buffering =
true limit-post = 17179869184 http-timeout = 1200 harakiri = 1200 • https:/ /uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html • https:/ /uwsgi-docs.readthedocs.io/en/latest/Fastrouter.html#post-buffering-mode-uwsgi-2-0-9 • https:/ /uwsgi-docs.readthedocs.io/en/latest/Options.html?highlight=options
Conclusiones • Definir volumen y tamaño de archivos. • Aprovechar
artefactos y no reinventar. • Tener en cuenta visión general de arquitectura. ◦ Configuraciones • Iterar...
¡Muchas Gracias! @emimartin26
[email protected]