u:p:
« prevnext »

Performance considerations when using script objects

Introduction

Scripts had been introduced in VoiceObjects as a way of dealing with complex computations that either couldn't be done at all using Expressions, or that required such a large number of nested Expressions that building them would be highly tedious.
Over time, however, the Script object has become a sort of "catch all" that is being used wherever anything remotely computation-like is required - like Script objects that did nothing more than assign static values to variables.
While this has a certain level of convenience for the developer, it also has a major, often under-appreciated, impact on performance and scaling.

High-Level Guidelines

These Guidelines should help the developer understanding the performance impact of his choice of objects. These guidelines should be kept in mind when developing an application - especially when the load on this application is expected to be high.

  • Use Expressions wherever possible
    Expressions scale at least 10 times better than Scripts. So a bit more time spent during development goes a long way in production deployment
  • If you use Scripts, do as much as possible in them
    The main overhead in using Script objects comes from the initialization of the JavaScript engine. Once it runs, the impact of what exactly you do in it is almost negligible. So merely assigning a constant to a variable costs essentially the same as computing the first 5,000 digits of pi.
  • Avoid using Script objects in other frequently visited places
    Keep in mind that there is the twofold impact of how often each individual session evaluates a Scripts and how many sessions evaluate Script objects in parallel.
    As an example, using a Script as the very first object that is processed when a new call comes in might not be an optimal choice since under high load, with many calls coming in simultaneously, you can predict that there will be many sessions evaluating this Script at essentially the exact same time. This will trigger significant load peaks and throttle scalability.
  • Never use a Script object as part of a Resource Locator definition
    These are potentially evaluated multiple times for each single dialog step, leading to extreme degradation in response times and scaling.
  • Never use a Script as a condition in a Layer state
    As Script values cannot be cached these also need to be re-evaluated whenever the Layer is used.
Was this page helpful?  
Last edited by:kschmitte on: 9/18/2009 8:09 AM (EDT)

Tags:
Edit  | Tags | Files | Info | Options | Subscribe |


©2002-2012 Voxeo Corporation  -  VoiceXML Hosting  -  VoiceXML Servers  -  Site Map  -  Terms of Use  -  Privacy Policy  -  Covered by U.S. Patent No. 6,922,411