Variables & Constants

Comments

3 comments

  • Rogier Mulhuijzen

    Do you have examples of the sort of things you have in mind as constants?

    VCL is compiled to C, and then to machine code, and C compilers can do a lot of optimization, so I'm not sure there's a lot of waste going on, but I can most certainly check.

    0
    Comment actions Permalink
  • ryantownsend

    @drwilco we have a few:

    • The threshold of users allowed on to the site. Generally, this is left set to 100%, but can be lowered to limit traffic in event of exceptionally-high origin load.
    • Maintenance page toggle. Used to mask the system when updates requiring downtime are made.

    In both instances, we will adjust the values in VCL and activate the new version.

    0
    Comment actions Permalink
  • Rogier Mulhuijzen

    Ah, good points. We (SEs and other VCL users at Fastly) have been using Edge Dictionaries for that. Basically we will have a settings table, and have various keys for knobs to tweak. And if used a lot, we'll load the values into local variables, especially if there's conversion.

    With Edge Dictionaries you get the ability to do a change to a value with a single API call. And now that you can batch updates, you can even change multiple values with a single API call, and forego having to clone & activate.

    Other than datatype, there's no real advantage over using dictionaries to constants. Dictionaries allow for flexibility and a more general usecase, whereas constants would require us to know which variables have to be there, which complicates our controlplane a lot. Edge Dictionaries can cover missing "variables", by using table lookups with a supplied default value.

    0
    Comment actions Permalink

Please sign in to leave a comment.