ENع
→Storage
الدرس 05 · السحابة

Cloud storage

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

10 دقائق9 خطوات5 أسئلةBeginner
عن هذا الدرس

Cloud storage is disk space you rent and reach over a network. Meet its three kinds: a block volume that acts like a drive plugged into one server, a file share that many servers open at once, and an object bucket that holds whole files found by key. Then follow one photo as five lines of Python upload it to a bucket, the provider copies it into three zones, one zone goes dark, and a second server downloads it.

ستتعلّم

حدّد ما تشعر بأنك أتقنته. هذا التقييم الذاتي لا يؤثر في درجة الدرس.

شكل 5 · تفاعلي
01 / 09

Disk space you rent

Cloud storage is disk space you rent from a provider and reach over a network. You pay for what you use or reserve, usually per gigabyte per month. It comes in three main kinds: block, file and object storage.

cloud storage = rented disk space, over a network
pay for what you use or reserve (per GB per month)

block   a drive for one server
file    a folder many servers share
object  a bucket of files found by key
جارٍ تحميل الرسم…
أو ← →
اقرأ الدرس خطوة بخطوة
  1. Disk space you rent

    Cloud storage is disk space you rent from a provider and reach over a network. You pay for what you use or reserve, usually per gigabyte per month. It comes in three main kinds: block, file and object storage.

    cloud storage = rented disk space, over a network
    pay for what you use or reserve (per GB per month)
    
    block   a drive for one server
    file    a folder many servers share
    object  a bucket of files found by key
  2. Block: a drive for one server

    A block volume acts like a hard drive plugged into one server. The operating system formats it and saves files on it in fixed-size pieces called blocks. It is fast, so databases use it. AWS calls it EBS (Elastic Block Store).

    Server 1 ── Block volume
    
    the OS sees a blank drive: /dev/xvdf
      format it, mount it, save files
    one server at a time, in one zone
    AWS EBS · Google Persistent Disk · Azure Disk Storage
  3. File: one folder, many servers

    A file share is a folder that many servers open at the same time, over a network protocol such as NFS. One server saves a file and another can read it. AWS calls this EFS; Google calls it Filestore.

    Server 1 ─┐
              ├── File share  /shared/menu.txt
    Server 2 ─┘
    
    NFS: Network File System
    AWS EFS · Google Filestore · Azure Files
  4. Object: a bucket of keyed things

    Object storage keeps whole files, called objects, in a bucket. Each object has a key (its name), the data and metadata (facts about it, like its size). The key menu/latte.jpg looks like a folder path, but the bucket is flat.

    bucket "cafe"
      key       menu/latte.jpg
      data      the bytes of the photo
      metadata  size, Last-Modified date
    
    "/" is just a character in the key:
    no real folders, one flat list of keys
  5. Upload: PUT by key

    Server 1 runs line 4. The boto3 library sends the photo to the bucket over HTTPS as a PUT request, with its key. There is no drive to plug in and no folder to mount: any program with permission can do this.

    s3.upload_file("latte.jpg", "cafe", key)
    
    PUT /menu/latte.jpg  (to the bucket "cafe")
    <the bytes of latte.jpg>
    → 200 OK
  6. Copies in three zones

    By default, S3 copies each object into at least three Availability Zones: separate groups of data centres in one region, each with its own power and network. AWS designs S3 for 99.999999999% (eleven nines) yearly durability.

    one PUT → copies in three zones
      Zone A  ✓
      Zone B  ✓
      Zone C  ✓
    
    designed durability: 99.999999999% per year
  7. A zone goes dark

    Say Zone A loses power. The copies in Zones B and C still answer, so the photo is neither lost nor out of reach. S3 Standard is designed to keep data safe even if a whole zone is lost.

      Zone A  ✗ no power
      Zone B  ✓ answers
      Zone C  ✓ answers
    
    the photo is still safe and readable
    (S3 One Zone-IA keeps one zone only)
  8. Download: GET by key

    Line 5 asks for the same bucket and key with a GET request, and the photo comes back as copy.jpg. Server 2 fetches it here: nothing was shared or plugged in, only a name and permission.

    s3.download_file("cafe", key, "copy.jpg")
    
    GET /menu/latte.jpg  (from the bucket "cafe")
    → 200 OK
    <the bytes> → copy.jpg on Server 2
  9. Which kind, when

    Use block storage for one server's boot disk or database, file storage for a folder many servers share, and object storage for photos, videos, backups and logs reached by key. Most real apps use more than one.

    block   one server's boot disk or database
    file    a folder many servers share
    object  photos, videos, backups and logs
    
    most apps mix them:
      a database on block, uploads in a bucket

اختبار يتاح بعد الخطوة الأخيرة.