Scaling Issues

Understand the symptoms, causes, and the diagnostic information needed to go after scaling issues.

What are scaling issues?

Scaling software deserves its own course. Scaling software to meet increased demand frequently occurs in distributed systems. In this lesson, we’ll briefly learn about scaling from a debugging perspective. Most ideas and concepts apply specifically to distributed systems. Scaling issues are seen when a software system is overwhelmed by input at a size or a rate it was not designed to handle.

Let’s consider an example. The code below takes in a set of strings and a file name as input and searches the file for the strings passed in as input.

#!/usr/bin/env python
import sys
import time
# List of search words
searchWords = ['course', 'education', 'debugging', 'code']

# Function to check if words in wordList are present in allWords
def findWords(wordList, allWords):
    return [w in allWords for w in wordList]  # Return a list indicating if each word is present in allWords

# Define main function
def main():
    start_time = time.time()  # Record the start time
    searchWords = ['course', 'education', 'debugging', 'code']  # List of words to search for
    if len(sys.argv) == 1:  # If no additional arguments were passed
        print("enter file to search in")  # Prompt the user to enter a file name
        return  
    filename = sys.argv[1]  # Get the filename from the command line arguments
    with open(filename) as file:  # Open the file
        lines = [line.rstrip() for line in file]  # Create a list of all lines in the file, removing trailing whitespaces
    print (findWords(searchWords, lines))  # Print the result of the findWords function
    print("--- time taken %s seconds ---" % (time.time() - start_time))  # Print the elapsed time
    return 

if __name__ == '__main__':
    main()
Scaling issues

Invoke Scale.py against small.txt by issuing python3 Scale.py small.txt. Observe the output and invoke it against large.txt in a similar manner. We can notice that the code works fine for the inputs provided, and ...