Mengonfigurasi kebijakan pembatasan kapasitas layanan

Dokumen ini menjelaskan cara mengonfigurasi kebijakan pembatasan frekuensi layanan untuk Secure Web Proxy guna melindungi sistem Anda dari kelebihan beban traffic dan mengelola biaya traffic web keluar.

Sebelum memulai

Menyiapkan kebijakan pembatasan kapasitas layanan

Untuk membuat kebijakan pembatasan kapasitas layanan, tentukan konfigurasi Anda dalam file YAML, lalu impor file tersebut ke Secure Web Proxy.

  1. Buat file my-rate-limit-policy.yaml, lalu tentukan parameter kebijakan.

    Contoh berikut membatasi jumlah permintaan yang dikirim ke penyedia model bahasa besar (LLM) (foo.com) menjadi 100 permintaan per menit untuk setiap agen di gateway Secure Web Proxy untuk traffic keluar. Setiap agen diidentifikasi dengan nama umum dalam sertifikat kliennya.

      name: "projects/ PROJECT_ID /locations/ LOCATION /rateLimitPolicies/test-policy"
      description: "Simple agent for LLM rate limiting."
      httpRules:
      # Match on the provider host name.
      - to:
          destination:
            hosts:
            - exact: "foo.com"
    
        # default RPM bucket
        rateLimitActions:
        - rateLimitBucket: "rl_default_rpm_limit"
    
      rateLimitBuckets:
      - name: "rl_default_rpm_limit"
        # Identify client by its client cert name
        keys:
        - keyType: PRINCIPAL
          principalType: CLIENT_CERT_COMMON_NAME
        defaultLimit:
          countLimit:
            count: 100
            interval: 1
            intervalUnit: MINUTES
    
      targets:
      - resource: "projects/ PROJECT_ID /locations/ LOCATION /gateways/ GATEWAY_NAME "
    

    Ganti kode berikut:

    • PROJECT_ID: ID project Google Cloud Anda
    • LOCATION: region instance Secure Web Proxy Anda; misalnya, us-central1
    • GATEWAY_NAME: nama instance gateway Secure Web Proxy Anda
  2. Impor file YAML kebijakan pembatasan kapasitas menggunakan perintah berikut:

    gcloud alpha network-security rate-limit-policies import test-policy \
      --source=my-rate-limit-policy.yaml \
      --location=LOCATION
    

    Ganti LOCATION dengan region instance Secure Web Proxy Anda.

Langkah berikutnya