Luyện nói tiếng Anh bằng Shadowing qua video: Design a File Upload Service Like a Senior Engineer

Đang tải...
1
How can you design a scalable file upload service?
2
In this video, I'm going to walk you through a system design discussion where
3
we are going to build a file upload service step by step, starting from a very simple scenario and then expanding it into a more reliable and scalable solution.
4
So let's start by listing out some requirements for our file upload service.
5
These are going to be our functional requirements
6
and we need to be able to upload
7
and download files, obviously we need to be able to work with large files we need to make our system secure
8
and we also have to allow for async processing of the files
9
so that our users don't have to wait too long
10
or any background work that we have to perform behind the scenes
11
so you may start simple where you have your clients
12
and they have some files that they want to upload to our API
13
so let's add a component here this is going to be our file upload API
14
and this is going to be their entry point for their initial request.
15
So they're going to send the request to our API
16
and we could have an endpoint like files and then slash upload for example.
17
We're also going to need some database and this is going to hold our files and metadata for our initial implementation.
18
It doesn't really matter which specific database we're using but let's say it's some sort of relational database.
19
So our API needs to be able to store the data inside of our database
20
and this could be our initial primitive implementation.
21
Now let's look at our functional requirements.
22
So we'll be able to upload and download files, store our metadata.
23
Now the ability to work with large files is somewhat questionable as all of the requests are flowing through our API.
24
So it's going to quickly become a bottleneck
25
if many users are attempting to upload a file at the
26
same time as we have to buffer the file in memory before we can store it in our database.
27
So I'm going to leave a question mark there even though we should probably fail this requirement.
28
When it comes to security we can still secure this just fine
29
and then async processing is somewhat possible with background services but if it's all still running on our single API instance, then we're going to quickly run into the same bottlenecks.
30
Another problem that we're going to run into is with the fact
31
that we are initially storing the files and the metadata in our database.
32
So most databases can store binary data just fine, but this is going to cause problems with page size explosion, as we can assume these files can be large,
33
and most databases have an upper limit on how large a single page can be.
34
So you can imagine a single file spanning multiple database pages, and this incurs more costs when writing to the database and also querying from the database.
35
So it's something to keep in mind.
36
And this is where we could reach out to a more specialized solution for working with files.
37
So we can introduce another component into our system, and we're going to call this the object store.
38
So these are specialized services.
39
So I'm going to give you a couple examples.
40
So let's say something like SV or Azure Blob Storage, and they are designed to work with files efficiently.
41
So with the object store now part of our system, we're going to slightly alter how clients are interacting with the file upload API.
42
So what's going to happen is instead of having an endpoint to directly upload the file to our API, we're going to introduce a different API endpoint.
43
So let's add it here and let's call it something like files pre-signed upload.
44
So the idea here is we get what's called a pre-signed URL
45
and it's supported by most of these object stores
46
and this gives you a secure URL that allows you to send a request directly to the object store.
47
So after getting the pre-signed URL, our client is then going to send another request
48
which is going to upload the file directly to the object store
49
and this fixes a couple of big bottlenecks inside of our system.
50
So first of all the file upload API is no longer
51
a single point of failure as we can now upload
52
and download files from the object store using pre-signed URLs
53
which means we still have security as our users have to send the initial request to the upload API
54
which means they have to be authenticated in order to even get a pre-signed URL
55
and then we can get the benefits of object stores where they can work with large files.
56
They also have support for multi-part upload
57
which means we can break up a large file into multiple chunks and then stream those to the object store.
58
This also gives us the ability to pause and resume uploads.
59
We also get support for deduplication and we also get support for controlling file retention.
60
So instead of redesigning something like S3 from scratch, we can simply leverage it as another component inside of our file upload API.
61
Another component we need to support is the ability to have async processing.
62
So let's say we need to do a couple of operations behind the scenes after a file is uploaded.
63
So I'm going to add a couple of components here.
64
So let's say we need to perform virus scanning.
65
Then we could have things like thumbnail generation or more general preview generation.
66
We could perform things like optical character recognition or something more general like validation.
67
So all of these can be fairly long-running operations, especially when we need to support a large number of file uploads.
68
So how do we implement async processing for all of these operations?
69
Well, we need to introduce another component into our system.
70
So let's add some sort of pipeline and this is going to be our queue.
71
Let's add it here below the database and then we have a couple of ways how we could integrate this.
72
Either we could have our object storage enqueue a message after upload
73
and this could kick off the processing inside of our background services as simple message consumers
74
or we could have our object storage send some sort of callback to our file upload API
75
and then our file upload API would be responsible for sending a message to the queue on behalf of the object store.
76
I think the first approach here is probably more scalable as most object stores already have support for this built-in
77
and they can integrate with many popular messaging systems.
78
So let me actually move all of these components over here
79
as I'm going to need the bottom part of the screen for one more thing we want to add
80
and that is after mostly solving the file upload part we also have to solve how to reliably
81
and securely allow our users access to these files which means giving them the option to download the files.
82
So for this we can introduce what's called a content delivery
83
network where our clients can send a request to download the file and if it's not available, the content delivery network can reach out to our API to provide this file
84
and this is mostly good for public or static files.
85
So you can think of things like documentation that can be publicly accessible and things that don't change that often.
86
Of course, static assets for your website.
87
And why a content delivery network is good is
88
because it's usually globally distributed and it can route your user's request to the geographically closest component.
89
Now, what about requests for some specific files?
90
Those we can route directly to our API.
91
And to implement this securely, we're also going to utilize pre-signed URLs, except this is going to be some sort of download endpoint for example
92
and this is going to follow a similar idea as uploading to the object store
93
and is going to allow our clients to leverage the power of our object store to get access to their files.
94
So this final design should now check most of our boxes.
95
We can upload and download file, we can store the metadata either in the object store
96
or inside of our custom database and we can pull this value after a callback
97
or we can consume the message from a queue.
98
We can work with large files as most object stores support this.
99
We also have security built in as we have dedicated access
100
control for each file we can make them public we can make them private we can share them between users
101
and we've also got the ability to do async processing as
102
we can pick up messages from a queue from some background worker
103
and perform the work behind the scenes and then notify our file upload service
104
when the processing is done and lastly i just want to leave off with an idea
105
if you want to self-host an object store there are open source options out there like for example rustfs
106
which is fully s3 compatible and you could run it on your own system
107
if for some reason you don't want to use a cloud solution like AWS S3 or Azure Blob Storage.
108
And another option I ran into is Seaweed FS.
109
There are options out there like Mini.io, which was open source but now isn't, then Rust FS or Seaweed FS, and I'm going to leave some useful resources and links in the description of this video.
110
Let me know in the comments what you would change about this design
111
and what other considerations you would have made that I may have possibly missed.
112
Also, if you would like to see more system design discussions like this one, consider leaving a suggestion for what topic I should cover.
113
If you enjoyed this video, gently tap the like button to let me know.
114
Thanks a lot for watching, and until next time, stay awesome!

Tại sao nên luyện nói với video này?

Video này mang đến cơ hội tuyệt vời để luyện nói tiếng Anh thông qua phương pháp shadowspeak. Bạn sẽ được dẫn dắt qua quá trình thiết kế dịch vụ tải tệp, từ khâu đơn giản đến các giải pháp mở rộng hơn. Việc luyện nói với video giúp bạn không chỉ cải thiện khả năng phát âm, mà còn nâng cao khả năng phản ứng nhanh và hiểu biết ngữ cảnh. Bằng cách lặp lại theo cách mà người nói thể hiện, bạn sẽ phát triển kỹ năng ngôn ngữ của mình một cách tự nhiên và hiệu quả, tạo điều kiện cho việc luyện nghe nói qua video trở nên thú vị hơn.

Ngữ pháp & Biểu thức trong ngữ cảnh

  • How can you design...: Câu hỏi mở . Cấu trúc này khuyến khích bạn diễn đạt suy nghĩ và giải pháp của mình.
  • We need to be able to...: Cấu trúc "need to" thể hiện nhu cầu cần thiết, giúp người học có thể áp dụng khi bàn luận về yêu cầu hoặc mong muốn.
  • It's going to quickly become a bottleneck...: Cách sử dụng thì tương lai gần (it's going to) đúng ngữ pháp giúp bạn mô tả hiện tượng sắp xảy ra một cách linh hoạt.
  • This fixes a couple of big bottlenecks...: Sử dụng từ "fix" trong bối cảnh này giúp bạn cải thiện khả năng diễn đạt vấn đề và giải pháp.

Một số cạm bẫy phát âm thường gặp

Khi nghe video, bạn sẽ gặp một số từ ngữ có thể gây khó khăn cho phát âm. Chẳng hạn:

  • Scalable: Đảm bảo bạn nhấn âm đúng để từ này không trở thành scaleble.
  • Metadata: Từ này có thể khó phát âm với những người không quen, nên hãy luyện tập nhiều lần.
  • Asynchronous: Từ này có âm tiết dài, hãy chú ý đến âm cuối để tránh phát âm thiếu chính xác.

Những từ và cấu trúc này không chỉ giúp bạn nắm bắt nội dung của video mà còn mang đến cho bạn những kỹ năng phát âm quan trọng trong tiếng Anh. Bằng việc luyện tập thường xuyên với các video như thế này, bạn sẽ có thể nâng cao kỹ năng nói của mình một cách tự tin hơn.

Phương Pháp Shadowing Là Gì?

Shadowing là kỹ thuật học ngôn ngữ có cơ sở khoa học, ban đầu được phát triển cho chương trình đào tạo phiên dịch viên chuyên nghiệp và được phổ biến rộng rãi bởi nhà đa ngôn ngữ học Dr. Alexander Arguelles. Nguyên lý cốt lõi đơn giản nhưng cực kỳ hiệu quả: bạn nghe tiếng Anh của người bản xứ và lặp lại to ngay lập tức — như một "cái bóng" (shadow) đuổi theo người nói với độ trễ chỉ 1–2 giây. Khác với luyện ngữ pháp hay học từ vựng bị động, Shadowing buộc não bộ và cơ miệng phải đồng thời xử lý và tái tạo ngôn ngữ thực tế. Các nghiên cứu khoa học xác nhận phương pháp này cải thiện đáng kể phát âm, ngữ điệu, nhịp điệu, nối âm, kỹ năng nghe và độ lưu loát khi nói — đặc biệt hiệu quả cho người luyện IELTS Speaking và muốn giao tiếp tiếng Anh tự nhiên như người bản ngữ.