All Products
Search
Document Center

Server Load Balancer:How AScript works

Last Updated:Feb 04, 2024

AScript allows you to use scripts to customize forwarding rules when the standard forwarding rules in the Application Load Balancer (ALB) console cannot meet your business requirements. This topics describes the model and execution positions of AScript and how it works.

How it works

Same as standard forwarding rules in the ALB console, AScript is used to define how requests are processed by ALB.

When a request reaches ALB, ALB processes the request based on the forwarding rules configured in the ALB console. AScript can execute scripts to process the request before or after forwarding rules are applied.

Model

Scripts are executed based on the following model:

  • AScript executes scripts to achieve different functions. Functions are triggered only when the conditions in scripts are met.

  • You can specify the position where a script is executed and the priority of the script in a request processing pipeline.

  • Scripts are managed based on listeners.

Execution positions

You can configure scripts to be executed before or after an inbound forwarding rule is applied, or before an outbound forwarding rule is applied. The function that you can achieve varies based on the execution position:

  • Before an inbound forwarding rule: For example, you can automatically rename frequently files, convert file extensions to lowercase letters, add URI prefixes, and rewrite file extensions.

  • After an inbound forwarding rule: For example, you can automatically rename frequently files, convert file extensions to lowercase letters, add URI prefixes, and rewrite file extensions.

  • Before an outbound forwarding rule: For example, you can automatically rename frequently files.

Script execution

Description:

  • Script ID: indicates the status of a script.

  • The following table describes the execution information about scripts in different states.

    Script ID

    Description

    -1

    The default value.

    1

    The script is not executed.

    2

    The condition is met.

    if condition {} is specified in the script and the condition is met.

    3

    No condition is met.

    if condition {} is specified in the script but the condition is not met, or if condition {} is not specified.

    4

    Script execution fails. Possible causes of error:

    • 400 : not found inline func %s

    • 401 : not found argument %d in %s

    • 402: mismatch string type of arg %d in %s

    • 403: mismatch number type of arg %d in %s

    • 404: mismatch table type of arg %d in %s

    • 405: mismatch boolean type of arg %d in %s

    • 406: mismatch function type of arg %d in %s

    • 407: exceed the exec cputime limit %d-%d us

    • 408: exceed the api call limit %s %d-%d times

    • 409: exceed the max loops limit %d in m3u8_rewrite

    • 410: exceed the max loops limit %d in foreach

    • 499: unknown reason

  • Execution time:

    • Unit: microseconds.

    • Default value: -1.

    • Execution time displayed on the web interface:

      • Tier 1: 0 to 100

      • Tier 2: 100 to 500

      • Tier 3: 500 to 1000

      • Tier 4: 1000 to 5000

      • Tier 5: 5000 to 20000

      • Tier 6: 20000 to 50000

      • Tier 7: above 50000

  • The execution is suspended:

    Default value: -1.

References