Reliability of a Function

◀ Memory Footprint of a Function▶ Generality of a Function
Amazon Reliability describes how reliable your function is, especially under extreme conditions such as extreme workload and bad or unpredictable arguments. Does your function crash on certain arguments or under big stress? Does your function act strange given some specific control flow? Is your function fault tolerant?

Ideally, your function should never crash no matter what the arguments may be. The worse thing it can do is return some error code to the program so that the program can exit gracefully.
At times this is hard to achieve; for instance, you expect the user to give a file according to a specific format. If file is completely out of accordance with that format, how does the designated function process that file? One way to do this is check the validity of the file before you process it. Another way is to check while processing it. In any case your function cannot act abnormally no matter what.

Does your function crash under heavy stress? If your function creates a thread for every request infinitely then it could run out of memory.

A classic example is a web server. A web server serves HTTP requests from clients. If ten thousand clients make an HTTP request to the server, the server needs to handle the load gracefully. One way to do this is simply limit the number of threads the function creates.
If you are writing functions packaged in a third party library you’ll need to make sure the functions are robust and reliable so that when people use your library they won’t get incorrect results or even get their program crashing.

A straightforward way to do so is check the arguments to make sure they are acceptable by your function. If they don’t return some error code depending on the nature of your function. Whatever you do state it clearly in the comment above the function.

Next we’ll look at the generality of a function!
◀ Memory Footprint of a Function▶ Generality of a Function

Questions? Let me know!