跟讀練習: Design a File Upload Service Like a Senior Engineer - 通過影片學習英語口語

選擇練習模式

每種模式都會開啟全屏練習室。

114 句
如果句子過短或過長,請點選 Edit 進行調整。
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!

下載應用

流利口語所需的一切

AI 發音評分逐句打分
音標練習掌握每個音
詞彙學習建立你的詞庫
詞彙遊戲邊玩邊學
FOR YOU

推薦影片

為什麼通過這個影片練習口語?

觀看這段影片後,您將能夠更有效地理解如何設計一個可擴充套件的檔案上傳服務。在學習過程中,您不僅能掌握技術知識,還能夠提升您的英語口語能力。這是因為影片講解了實際的場景和需求,您可以通過模仿和重複練習來培養流利的口語。這種英語口語練習方法特別適合想要提升專業詞彙和口語表達能力的學習者。

語法與表達方式在語境中的分析

  • 條件句:影片中講到“如果許多使用者同時上傳檔案,系統會迅速成為瓶頸。”這樣的句子結構幫助您理解如何在描述條件和結果時使用條件句,這在實際交流中非常重要。
  • 動名詞的用法:影片提到了“工作為非同步處理檔案”,這個結構可以幫助您在談論活動或行為的同時使用動名詞。
  • 專業術語:從“物件儲存”到“預簽名URL”等詞彙,都能幫助您在技術交流中更加準確表達意見。
  • 被動語態:使用“檔案可以儲存在資料庫中”等被動語態,讓您在談論複雜操作時能更加專業。

常見發音陷阱

在影片中,可能會出現一些令人困惑的發音,特別是在技術術語方面。例如,“upload”(上傳)的發音在快節奏的語境中可能會被模糊,而“metadata”(後設資料)則在不同的口音中也可能有所不同。注意練習這些詞彙的發音,可以幫助您在與同行對話時更加自信。

通過模仿影片中的發音和用法,您可以更好地掌握這些技巧,並在日常交流或工作中自如運用。英語口語練習並不僅限於記憶,更在於實際的交流能力提升。利用這些資源,您將能夠更加流利地進行英語對話。

什麼是跟讀法?

跟讀法 (Shadowing) 是一種有科學依據的語言學習技巧,最初開發用於專業口譯員的培訓,並由多語言者Alexander Arguelles博士普及。這個方法簡單而強大:您在聽英語母語原聲的同時立即大聲重複——就像是一個延遲1-2秒緊跟說話者的影子。與被動聽力或語法練習不同,跟讀法強迫您的大腦和口腔肌肉同時處理並模模擬實的講話模式。研究表明它能顯著提高發音準確性,語調,節奏,連讀,聽力理解和口語流利度——使其成為雅思口語備考和真實英語交流最有效的方法之一。

影子跟讀法: 閱讀完整分步指南 →