シャドーイング練習: Design a File Upload Service Like a Senior Engineer - 動画で英語スピーキングを学ぶ

読み込み中...
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!

この動画で話すことを練習する理由は?

この動画は、ファイルアップロードサービスを設計するプロセスについて詳しく説明しています。英語を学ぶ過程で、テクニカルなトピックに関する会話は特に重要です。この動画を使ってshadow speakを行うことで、専門用語や技術的な表現に慣れることができ、より自信を持って会話できるようになります。また、こうした内容は実際のビジネスシーンでもよく使われるため、就職活動や業務において大きな強みとなるでしょう。英語の発音を良くするためには、このような専門的な対話を通じて実践することが非常に効果的です。

文法と表現のコンテキスト

動画内では、以下のような重要な文法構造や表現が使われています:

  • 「how can you design a scalable file upload service?」 - 質問形を使って、聞き手に考える余地を与えています。このような疑問文は、相手に深く考えさせる動きを促します。
  • 「we need to be able to upload and download files」 - 不定詞の用法が使われており、目的を明確にしています。この表現は、要件を説明する際に非常に効果的です。
  • 「this is going to be our entry point for their initial request」 - 未来進行形を用いることで、今後の展望を語る場面が強調されます。計画や予測について議論する際に役立つ表現です。

一般的な発音の罠

動画に登場するいくつかの単語やフレーズは、発音が難しい場合があります。ここでは特に注意が必要な単語を挙げてみます:

  • 「scalable」 - スカラブルは、音節が多く、発音の際に注意が必要です。正確に発音することで、プロフェッショナルな印象を与えられます。
  • 「upload」 - アップロードの発音はしばしば混乱を招くため、リズムに合わせて練習することが大切です。
  • 「metadata」 - メタデータは比較的一般的な用語ですが、アクセントの位置に気を付けて発音することが重要です。

これらの表現や単語を用いて、shadowspeakを行うことで、自信を持って専門的な話をする能力を高めましょう。また、発音トレーニングとして、英語の音声模写を行うことが効果的です。

シャドーイングとは?英語上達に効果的な理由

シャドーイング(Shadowing)は、もともとプロの通訳者養成プログラムで開発された言語学習法で、多言語習得者として知られるDr. Alexander Arguelles によって広く普及されました。方法はシンプルですが非常に効果的:ネイティブスピーカーの英語を聞きながら、1〜2秒の遅延で声に出してすぐに繰り返す——まるで「影(shadow)」のように話者を追いかけます。文法ドリルや受動的なリスニングと異なり、シャドーイングは脳と口の筋肉が同時にリアルタイムで英語を処理・再現することを強制します。研究により、発音精度、抑揚、リズム、連音、リスニング力、そして会話の流暢さが大幅に向上することが確認されています。IELTSスピーキング対策や自然な英語コミュニケーションを目指す方に特におすすめです。