How Are Backoff Strategies (with Client Retries) Helpful?

Question
Sometimes a client attempts to connect to or use an application. Sometimes a Kubernetes Pod is being created and tries to pull down an image. Sometimes a network device tries to establish a connection to an endpoint. These attempts can initially fail. Retries can be attempted in rapid succession. To mitigate excessive attempts in a short amount of time (to not waste resources or cause a denial-of-service attack),

How Do You Troubleshoot OOM Errors with Restarting Pods in Kubernetes?

Problem scenario
You find out-of-memory (aka OOM) errors in Kubernetes. The node seems healthy. The pods keep restarting. What should you do?

Possible Solution #1
Are you using a burstable quality of service (aka QoS) with the pods? There may be a non-pod-specific reason and the burstable Pods are being starved of resources. The node may be getting requests for other pods with a superior quality of service.

Do Ordered Dictionaries in Python Consume More Memory than Regular Dictionaries?

Question
You are considered using ordered dictionaries in Python (e.g., because of the way they handle temporal data). Will your program use more memory this way compared to using a regular dictionary?

Answer
Yes. All things being equal, ordered dictionaries use more memory than normal dictionaries.

# You will see that Python 3’s ordered dictionaries consume more memory than regular dictionaries
# This was adapted from https://lerner.co.il/2019/05/12/python-dicts-and-memory-usage/

import sys
from collections import OrderedDict

x = OrderedDict()
y = {}

for i in range(1, …

What Is The Time Complexity when There Are Four Variables Used Arithmetically in a Program?

Question
You have a program with four variables that are used in arithmetic, but no other operations happen. (There are no while or for loops at all.) What is the time complexity of such an algorithm?

Answer
O(1). An algorithm, as long as the number of operations is fixed or constant, can be considered to have O(1) time complexity. The source is page 39 of Elements of Programming Interviews in Python.

What Can Cause an Application to Run Slowly?

Problem scenario
You support an existing application and its servers. It is experiencing slowness as the users are complaining about its performance. What are some potential root causes of this slowness?

Possible Solutions

  • The slowness is caused by the client. A user’s workstation has something wrong with it (e.g., malware, or it is trying to run too many applications at once).

What is Memoization?

Question
In computer programming, what is memoization?

Answer
Memoization is the act of pre-computing or pre-processing certain values for the sake of an algorithm’s performance. Rather than perform the same exact operation (which could be very complex and computationally expensive) multiple times, memoization will involve writing code to compute it once and store it in memory as a variable. This optimization can allow the call stack to have less to store (e.g.,

For Storing Data for with Few Transactions and Little Loading with a Need for Compression, Would a Column-Oriented Database Be Better than a Row-Oriented Database?

Problem scenario
You are trying to select a database that is right for your needs. You will not be doing many transactions. The database does not need to support regular ETL or OLTP. You are going to have a large database, and you want it to compress to the smallest size possible. In some cases a column-oriented database better than a row-oriented database. What type of database should you use for this situation?

How Do You Fix a Python Program that Returns “Killed”?

Problem scenario
You are trying to write a Python program. It returns “Killed” on a Linux terminal. How should you fix this?

Possible Solution #1
“Aside from running time, the memory space occupied by a program is a principal cost.” (Taken from The Mythical Man-Month, page 238.)

Refactor your code. There is a programming method called “brute force” which is a reference to creating an exhaustive number of possibilities and processing those possibilities.

When Manipulating Lists in Python, Why is pop Slower than del?

Problem scenario
You use del and pop to remove items from lists. You noticed that pop is slower than del. Why is this the case?

Solution
There are two reasons. One, pop returns the value that is removed. Two, pop acts as a function call as opposed to a primitive action. Whereas the del invokes a primitive action (a non-recursive function call),