How Do You Install gRPC for Python on a Linux Server?

Problem scenario
You want to install gRPC and configure it for Python. How do you do this?

Solution
Prerequisites
You have installed pipe and venv. If you need assistance installing pip, see this posting for Ubuntu/Debian or this posting for a Red Hat derivative (e.g., RHEL, Stream, CentOS, Fedora) or this posting for SUSE. If you need help installing venv, see this posting.

Procedures
Run these commands:

python3 -m venv to_test
cd to_test
source bin/activate

Run this:

pip3 install grpcio

How Do You Get a Multi-line Variable in Python to Be Treated as Lines and Not Characters?

Problem scenario
When a number of lines of text are read from a file, the Python program sees each line as such. When a number of lines of text are in the program itself, that is you use a multi-line variable assignment in a .py program, Python sees the characters individually and does not distinguish between the different lines. The len() function reflects these differences. You want the Python program to read the text in the program as if it were read from the "with open" and "readlines()" function line-by-line -- not character-by-character.

For example, your source text could be like this in a standalone .txt file:

foo bar 123 456
cat dog 999 888
horse cow 333 777

When you read the .txt file in the Python program, each line of text is treated as a separate item in a list. In a Python program, you could have an assignment like this:

data1 = """foo bar 123 456
cat dog 999 888
horse cow 333 777"""

But the three lines would be treated as a single string -- not a list. You want data1 to be three lines of text and the len(data1) function to return 3. You do not want to have separate .txt files for the .py program to open. You want everything in a self-contained .py file.

What do you need to do?

Solution
Use .splitlines() and list(). Here is an example:

list(data1.splitlines())

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.

How Do You Rotate Certificates?

Problem scenario
You have load balancers, web servers, and other HTTP technologies that rely on SSL or TLS certificates. Some certificates will be revoked for security reasons. How do you provision new certificates to update them (because they will expire or you want to harden your environment by refreshing the certs as aged certs are more likely to be compromised than young ones)?

Solution
You may want to plan for having lower capacity than normal and therefore schedule the time to do this in production during an off-peak time.

Possible Solution #1
You could pay an third party company that is a certificate authority for new certs.

Possible Solution #2
Use AWS Certificate Manager
https://aws.amazon.com/certificate-manager/

Possible Solution #3
Use Google-managed SSL certs
https://cloud.google.com/kubernetes-engine/docs/how-to/managed-certs

Possible Solution #4
If you use Azure Active Directory, you could try AD certificate based authentication. See this Microsoft posting for more information.

Possible Solution #5
Azure App Service certificates. To use one, see this: https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-certificate

The benefits that are explained here: https://www.azuretechguy.com/azure-app-service-certificate

Possible Solution #6
Letsencrypt.org

Possible Solution #7
Install openssl and use it. If you need assistance using openssl, see these postings:

Possible Solution #8
If you use IoT and AWS, see this posting as Lambda functions can be readily leveraged to rotate certificates at scale.

Possible Solution #9
Use Cloud Conformity.

Possible Solution #10 (for CloudFront certs)
See this Amazon article.

Possible Solution #11 (for RDS certs)
See this Amazon article.

Possible Solution #12 (for Kubernetes)


To see how to rotate IAM keys, see this posting.

Should You Ask What the Salary Pay Range Is?

Problem scenario
You have applied for a job. You are curious what it can pay. Would the interviewer be upset if you asked what the expected pay range is for the position?

Solution
In some jurisdictions private employers must disclose the pay range. If you live in one of those places and you are asking for a remote position, it may be legally required for the employer to disclose it. You can then have an idea of what the job can pay. This can help you negotiate a higher salary or not waste time.

What is an Apache Web Server Container?

Problem scenario
You are reading about Apache Web Server containers. These are not related to Docker containers. You often see them near or tags. What are Apache Web Server containers?

Answer
They are portions of text that contain Apache web server configuration. (The source of this is https://httpd.apache.org/docs/2.4/sections.html.) The configuration includes directives often related to the VirtualHost in Apache web server. (To read what a VirtualHost in Apache is, see this posting.)

There are two basic types of containers. Most containers are evaluated for each request. The enclosed directives are applied only for those requests that match the containers. The <IfDefine>, <IfModule>, and <IfVersion> containers, on the other hand, are evaluated only at server startup and restart. If their conditions are true at startup, then the enclosed directives will apply to all requests. If the conditions are not true, the enclosed directives will be ignored.

https://httpd.apache.org/docs/2.4/sections.html

The containers can be individual files if their names end with ".conf" (according to https://wiki.centos.org/TipsAndTricks/ApacheVhostDir).

Containers can be at the bottom of the httpd.conf file to support different website domains (according to page 819 of RHCSA/RHCE Linux Certification Study Guide Sixth Edition by Jang (McGrawHill)).

See also What Is a Container in I.T.?

What is Long Tail Latency or Tail Latency in the Context of Application/Website/System Performance?

Question
What is long-tail latency or tail latency?

Answer
Tail latency is the worst performing time-measured response from an application. Outliers can be described as requests that take far longer than others in a statistical sample. Such irregular durations, with long latencies, are said to be at the tail-end of a chart or graph. Long-tail latency would generally refer to the worst 1% or worst 2% of the requests. (One source of this article is this external posting.)

See also page 15 of Designing Data-Intensive Applications by Kleppman. You may want to read about SLIs and SLOs here.

How Do You Find the Requests, Limits, and Replicas of Pods Deployed from Helm Charts?

Problem scenario
You do not have the YAML (.yml or .yaml) files for your Helm deployments.

How do you find the pod manifests for the yaml files when you do not have access to the Helm repos?

Solution
Run this:

helm ls -a -A

The output will show a "Name" on the left most column and a namespace in an inner column. (To learn more about these command see https://helm.sh/docs/intro/quickstart/ and https://v3.helm.sh/docs/helm/helm_list/.)

Next, run commands like this (but replace "foobar" with the name of the release/deployment you want to view the YAML for and replace "coolnamespace" with a namespace found in the above command):

helm get manifest foobar -n coolnamespace

(For more information, see these links: https://helm.sh/docs/helm/helm_get_manifest/ or https://helm.sh/docs/helm/helm_get/.)

Another command that may help is this (but replace "foobar" with the name of the release or deployment you want to view the YAML for):

helm list foobar --output yaml

(It was adapted from this stackoverflow.com posting.)

In Azure DevOps Pipeline Test Results, Why Do You See a Release That Was Not Run in a While?

Problem scenario
You look at some previous pipelines' test results. The tests show failing tests. There is a temporal field for "Failing since" and another field called "Failing release." You have not run the release that is listed as failing in a while. Why isn't it showing the most recent release?

Possible Solution
The root cause is consecutive failures and possibly a poorly named column heading. We believe the "Failing release" field omits the word "since." We believe it could be read as "Failing since release". In other words, we think the old release name that has had a failure is listed. Therefore the test results show it has been failing ever since then. That is why you do not see the most recent release.

For more information, you may find this external site helpful.

It could be that a more recent release was successful.