The system architect is key personnel to enable the success of an organization. From the book, Building Microservices, I learned the following worth highlighting nuggets:
An architect defines the technical vision of an organization. This vision is compatible with the strategic goals (e.g. expanding markets, market segments, etc) of the company. Taking an example of a town planner, an architect defines the zone in a town but not what goes in a zone. However, the architect defines how interaction happens among zones.
The technical vision is implemented by developers and the architect needs to ensure that vision is standard and adaptable too. It allows ease of development and a long-tern lower cost for the company.
The architect also needs to ensure that vision is translated sincerely in the product aka governance. The technical vision constantly evolves so an architect needs to stay top of the latest technical developments and have an open approach to refine and redefine the current vision.
defcountOneBS(row, start, end):if row[start]==0:return0if row[end]==1:return end - start +1# The mid is dependent on the index of start
mid = start +(end - start)//2# print("mid=", mid, "start=", start, "end=", end)return countOneBS(row, start, mid)+ countOneBS(row, mid +1, end)
Problem: Find the first non-repeating char in a string.
:type s: str
d = collections.OrderedDict()for index, c inenumerate(s):if c in d:
d[c]=[1, index]for k in d:if d[k]==1:return d[k]return-1
The leader serves writes and the client gets an ack after reliably storing the write with followers.
Each follower expects a heartbeat from the leader. If no heartbeat, a follower chooses to be a leader and ask for majority votes.
Each change to the system goes through the leader. There are three phases of a commit:
The leader appends the change in its log. A log entry has a term number & an index.
It then sends the change to followers.
A follower applies the change(not commit) in its log and ack the leader.
If the leader gets acknowledgment from the majority of the followers, leader commits the change and acknowledges the client.
In the next heartbeat, the leader notifies followers.
Followers apply the change.
Each leader gets a term. The term remains a unique, non-decreasing number in the cluster. The term number increases with each successful leader election.
A node can vote for only one candidate node in a term.
A node votes for a candidate whose log is at least the same index.
The candidate with maximum vote wins.
The leader with a higher term always wins. If there was a leader in a partition, the leader steps down and sync its log with the winner leader.