Thursday, May 20, 2021

Building Microservices: Designing Fine-Grained Systems 1st Edition

Building Microservices: Designing Fine-Grained Systems Paperback – March 3 2015


Distributed systems have become more fine-grained in the past 10 years, shifting from code-heavy monolithic applications to smaller, self-contained microservices. But developing these systems brings its own set of headaches. With lots of examples and practical advice, this book takes a holistic view of the topics that system architects and administrators must consider when building, managing, and evolving microservice architectures.

Microservice technologies are moving quickly. Author Sam Newman provides you with a firm grounding in the concepts while diving into current solutions for modeling, integrating, testing, deploying, and monitoring your own autonomous services. You’ll follow a fictional company throughout the book to learn how building a microservice architecture affects a single domain.

  • Discover how microservices allow you to align your system design with your organization’s goals
  • Learn options for integrating a service with the rest of your system
  • Take an incremental approach when splitting monolithic codebases
  • Deploy individual microservices through continuous integration
  • Examine the complexities of testing and monitoring distributed services
  • Manage security with user-to-service and service-to-service models
  • Understand the challenges of scaling microservice architectures

Walk 7 KM | May 18, 2021 | More than two hours, 30 minutes break

 I weighed myself twice a day. One is in the morning, the weight is around 204 lb. Evening is 3 lbs more.

On May 19, 2021, my weight was 201 lb. On May 20, 2021, my weight was 200.5 lb. 











Wednesday, May 19, 2021

T stock: The More It Drops The More I Buy: AT&T

May 19, 2021

I like to spend 20 minutes to go over the article, and also I like to learn more about AT & T business. 


The More It Drops The More I Buy: AT&T

May 19, 2021 8:35 AM ETAT&T Inc. (T)DISCANFLX419 Comments118 Likes

Summary

  • Bad news always sells better than good news.
  • News about the dividend cut has sent AT&T investors into panic mode.
  • The stock is down 8% in the last two trading sessions.
  • The deal with Discovery creates immediate big gains for shareholders.
  • Shareholders have 20% to 40% total returns over the next year until the deal with Discovery finalizes - using conservative estimates.
  • Looking for a portfolio of ideas like this one? Members of High Dividend Opportunities get exclusive access to our model portfolio. 

The More It Drops The More I Buy: AT&T

Note that the NewCo will have dramatically higher revenues than streaming peer Netflix (NFLX). In terms of scale, NewCo will be the behemoth of the streaming sector. When it comes to content, NewCo will have something for everyone. Warner has been a top 2 movie studio in 11 of the past 12 years, with tons of scripted TV shows along with premium sports rights. Meanwhile, DISC contributes the most popular "unscripted" content available today.

With more than 200,000 hours in content, this dwarfs their competition on sheer volume. NFLX, for example, has roughly 30,000 hours of content. The real kicker is that NewCo will own the content. NFLX has been facing the reality that as content producers like WarnerMedia start having their own streaming services, they will allow their distribution agreements to expire. This is what has been driving NFLX to invest increasing amounts of capital into developing its own content. Well, Warner has been producing content for more than 100 years, they have more than a little head start.

For content, NewCo will absolutely be competitive and likely blow away the competition. They have the advantage of sheer volume and diversity. 30 years ago, what will be available from NewCo would have been known as every channel on your cable subscription and would cost north of $100/month.

Valuation

One way to value the company is enterprise value/EBITDA (EV/EBITDA). At $14 billion in projected EBITDA for 2023, NewCo would be worth $182 billion at 13 times. Netflix is currently trading at 16 times EV/EBITDA.

To be conservative, we will just use 11 times EV/EBITDA, it would be worth $154 billion. Subtract $58 billion in debt, and that means the equity would be worth $96-$124 billion total. T shareholders will own 71% of that, or $68-$88 billion. That is $9.50-$12.33/current share of T.

And that's just to start. The new service will see significant growth and possibly outgrow Netflix in terms of number of subscribers.

Legacy T

Meanwhile, "Legacy T" (the company excluding WarnerMedia) is still a huge company, one that will be much better focused on their wireless and broadband. Post-split, T will still be producing more than $20 billion in free cash flow. That is $2.80/share.

Let's look at T's historical price to FCF:We can see that T's valuation has fallen dramatically to lows not seen since the Great Financial Crisis. Ironically, many have blamed this decline on T's acquisition of Time Warner. If that was indeed the culprit, then we should see T's valuation rebound back to 15 times!

Before T's acquisition of Time Warner, it routinely traded above 10x FCF outside of recessions. So how much is T worth post spin off? Well on the low-end, let's assume the value remains as low as it is today at 7 times. And on the high-end, let's assume 10 times - still a very conservative amount. That implies a valuation of $19.60-$28.00.

Sum Of The Parts

So for T shareholders:

  1. They will be getting shares in NewCo that are worth $9.50-$12.33. Arguably, NewCo could be worth much more, but we would want to err on the conservative side.
  2. Second, the legacy business would be worth $19.60-$28.00/share, assuming that it continues to trade at valuations consistent with those it had during the GFC and COVID. Call us crazy, but we don't consider GFC or COVID to be good comparable times for valuations.

That means that even with incredibly bearish valuations, T is worth $29.10 today at the minimum. Assuming still very conservative valuations, it is worth $40.33.

For The Shareholder

With the market panic about the prospects of a dividend cut over the past two days, investors have a great opportunity to buy the stock at very attractive valuations. Today, T is trading back close to $30/share.

Additionally, investors will have at least one more year of "big income" as T intends on paying out the full $2.08 dividend currently yielding 7%. The dividend will not be changed until after the spin-off.

A buyer today investing $30 will gain:

  1. $2.08 in dividends per year until the deal is closed.
  2. Two stocks (AT&T and the NewCo) with a combined worth $35-$40+ when the spin-off occurs in about a year.

That's a total return of 20%-40% in the span of about one year.

It's also entirely possible that the NewCo will be trading at such a high valuation that the AT&T investor who sells his share in the NewCo (when it starts trading or a few months later) and re-invests back the funds in AT&T may not lose a single penny of income.

We are not the only ones excited about this deal. According to Bank of America,

AT&T's stock could jump roughly 50% from current levels as its newly-formed media conglomerate with Discovery unlocks value.

Conclusion

The market can be an emotional place. Many investors will read one data point and panic. For this merger, many investors were either fixated upon the dividend and/or read some analysis that only showed one side of the coin, creating undue panic. Unfortunately, one-sided analysis can be hurtful for investors, and often results in unnecessary losses.

At High Dividend Opportunities, we're long AT&T and we took a decision from the start not to sell. I personally added to my position yesterday morning at open when the market was in full panic. I will be happy to buy more if the price drops further. Based on our conservative analysis, there are 20% to 40% returns over the next year by investing in AT&T today, holding on, or adding to your position.

How to study distributed system? | Chinese article

 

如何学习分布式系统

2019.05.01 23:07 8844浏览

前言

2019年,做大数据开发已经6年了,这期间分布式系统的知识学习了不少,但基本都是由于项目需要,没有系统性的融会贯通提纲挈领,在一件小事的触动之下,决定系统性的学习分布式系统。

网上搜索“如何系统性的学习分布式系统”,得到的答案都不是很满意,比如有的知识点过于零散,没有主线贯穿,有的太偏学术,都是看不懂也不知道有什么实际作用的算法。

因此决定自己列一个提纲,梳理一下分布式系统的知识,以分布式系统的特性为出发点,着重分析一些比较常用的开源软件中的实现原理,注重工程实践,减少理论研究,以设计思路为研究对象,便于自己的学习,也希望帮助他人。

具体学习路线

学习一项技术,要看它解决了什么问题,为了解决这个问题,它又具有哪些特性,这些特性又分别如何实现。

分布式系统解决什么问题就不过多解释了,无非是单一的节点无法满足业务需求,需要多节点协同工作。

一个分布式系统,具备以下特性:

  1. 一致性。分布式系统整体对外表现出的一致性由它的一致性模型决定。
    我们将会学习这些一致性模型:
    Sequential Consistency
    Causal Consistency
    Linearizability
    Session Guarantees for Weakly Consistent Replicated Data
    以及相关数学知识,也会研究一些分布式系统:
    zookeeper
    mongodb
  2. 时钟。系统通过事件发生的时间确定先后顺序。
    我们将会学习这些时钟:
    Lamport逻辑时钟
    Vector clock
    True Time
  3. 共识。分布式系统具备达到共识的能力。(计划介绍一些共识算法,例如raft)
  4. 扩展性。(计划介绍一些提高系统扩展性的东西,比如一致性hash)

这应该会是一个持续更新的路线图,同时也欢迎大家的意见和建议。
如何系统性的学习分布式系统?

本文首次发布于慕课网 ,转载请注明出处,谢谢合作

System design: distributed database consistency | Causal consistency

 

Causal consistency

From Wikipedia, the free encyclopedia
Jump to navigationJump to search

Causal consistency is one of the major memory consistency models. In concurrent programming, where concurrent processes are accessing a shared memory, a consistency model restricts which accesses are legal. This is useful for defining correct data structures in distributed shared memory or distributed transactions.

Causal Consistency is “Available under Partition”, meaning that a process can read and write the memory (memory is Available) even while there is no functioning network connection (network is Partitioned) between processes; it is an asynchronous model. Contrast to strong consistency models, such as sequential consistency or linearizability, which cannot be both safe and live under partition, and are slow to respond because they require synchronisation.

Causal consistency was proposed in 1990s [1] as a weaker consistency model for shared memory models. Causal consistency is closely related to the concept of Causal Broadcast in communication protocols.[2] In these models, a distributed execution is represented as a partial order, based on Lamport's happened-before concept of potential causality. [3]

Causal consistency is a useful consistency model because it matches programmers' intuitions about time, is more available than strong consistency models, yet provides more useful guarantees than eventual consistency. For instance, in distributed databases, causal consistency supports the ordering of operations, in contrast to eventual consistency.[4] Also, causal consistency helps with the development of abstract data types such as queues or counters. [5]

Since time and ordering are so fundamental to our intuition, it is hard to reason about a system that does not enforce causal consistency. However, many distributed databases lack this guarantee, even ones that provide serialisability.[6] Spanner does guarantee causal consistency, but it also forces strong consistency, thus eschewing availability under partition. More available databases that ensure causal consistency include MongoDB and AntidoteDB.

Definition[edit]

Causal consistency captures the potential causal relationships between operations, and guarantees that all processes observe causally-related operations in a common order. In other words, all processes in the system agree on the order of the causally-related operations. They may disagree on the order of operations that are causally unrelated.[1]

Let us define the following relation. If some process performs a write operation A, and some (the same or another) process that observed A then performs a write operation B, then it is possible that A is the cause of B; we say that A “potentially causes” or “causally precedes” B. Causal Consistency guarantees that if A causally-precedes B, then every process in the system observes A before observing B. Conversely, two write operations C and D are said concurrent, or causally independent, if neither causally precedes the other. In this case, a process may observe either C before D, or D before C. The Causal Precedence relation in shared memory is related to the happened-before relation in message-based communication.[3]

Thus, a system provides causal consistency if this following condition holds: write operations that are related by potential causality are seen by each process of the system in their causal precedence order. Different processes may observe concurrent writes in different orders.[7]

The Causal Consistency model is weaker than sequential consistency, which ensures that all processes observe all write operations in common order, whether causally related or not. [8] However, causal consistency is stronger than PRAM consistency, which requires only the write operations that are done by a single process to be observed in common order by each other process. [9] It follows that when a system is sequentially consistent, it is also causally consistent. Additionally, causal consistency implies PRAM consistency, but not vice versa.

Example[edit]

Here is an example of causal consistency. [10]

Causal relations are respected in the following event sequence:

P1 :W(x)1W(x)3
P2 :R(x)1W(x)2
P3 :R(x)1R(x)3R(x)2
P4 :R(x)1R(x)2R(x)3

Process P2 observes, reads, the earlier write W(x)1 that is done by process P1. Therefore, the two writes W(x)1 and W(x)2 are causally related. Under causal consistency, every process observes W(x)1 first, before observing W(x)2. Notice that the two write operations W(x)2 and W(x)3, with no intervening read operations, are concurrent, and processes P3 and P4 observe (read) them in different orders.

Session Guarantees[edit]

The causal consistency model can be refined into four session guarantees..[11] They can be summarised as follows:

  • Read Your Writes: If a process performs a write, the same process later observes the result of its write.
  • Monotonic Reads: the set of writes observed (read) by a process is guaranteed to be monotonically non-decreasing.
  • Writes Follow Reads: if some process performs a read followed by a write, and another process observes the result of the write, then it can also observe the read (unless it has been overwritten).
  • Monotonic Writes: If some process performs a write, followed some time later by another write, other processes will observe them in the same order.

Transactional session guarantees for serialisability and snapshot isolation are presented by Daudjee and Salem.[12]

Implementation[edit]

The system is abstracted as a set of communicating processes. When a process writes into the shared memory, the implementation sends this event to the other processes (via shared memory or as a message). Because of concurrency and failures, a process might receive events in any order. The implementation delivers an event, i.e., makes it visible to the process, only if all the events that causally precede it have themselves been delivered. This requires the implementation to maintain meta-data that represents the causal relationships between memory accesses.

In brief, the implementation includes the following steps: (1) Maintain causal context meta-data at every process to summarise what updates causally precede the current state. (2) When a process updates memory, tag the update event with the causal context of that process, to summarise what updates causally precede this update. (3) A process that has received some update event may deliver it only if the event's tag causally precedes the causal context of the receiving process. (As a side effect of delivery, add the new event to the causal context of the receiving process.) Otherwise, the update was received too early, and must remain buffered until event matches the context. In the meantime, the implementation either passively waits to receive the missing events, or actively fetches them from their source.

This approach enables availability under partition.[13]

There are two common representations for the causal context meta-data. One is to maintain an explicit dependency graph of the causal dependence relation. Because such a graph can grow arbitrarily large, an event is often tagged with only its immediate predecessors; determining its transitive predecessors requires a distributed graph traversal. The other is to maintain a vector clock, with one entry per process (or group of processes), counting the number of events generated by the process or group. This representation has a fixed size, and the ordering of events can be inferred by a simple comparison of the vectors.

To precisely determine which events are dependent and which are concurrent in a fully peer-to-peer system, the size of the metadata is at least proportional to the number of active writers.[14] However, a precise determination of concurrency is generally overkill. Causal consistency requires only that causally-dependent events be delivered in order; it does not matter if two concurrent events end up being ordered. Therefore, the size can be decreased arbitrarily by using safe approximation techniques. [15] In the limit, a single scalar (a Lamport clock[3]) suffices, at the cost of removing any concurrency. The size of metadata can also be decreased by restricting the communication topology; for instance, in a star, tree or linear topology, a single scalar suffices.

The search for efficient implementations of causal consistency is a very active research area.

GTE stock: 2021 Will Be Another Disastrous Year For Colombia’s Oil Industry

Here is the article.

原标题:2021年对哥伦比亚石油工业来说又是灾难性的一年

  中国石化新闻网讯 据今日油价4月19日报道,新冠肺炎疫情沉重地打击了哥伦比亚经济,其至关重要的能源部门,受到的冲击尤为严重。在实施了2020年期间世界上最长的出行限制措施之后,更是将经济推向崩溃的边缘。最近新冠肺炎病例急剧增加,迫使这个安第斯国家的主要城市重新采取封锁措施。受影响最严重的是热门旅游城市麦德林和哥伦比亚最重要的港口巴兰基利亚,目前已经实施了严格的宵禁和出行限制。这些措施将影响许多经济部门,包括至关重要的石油工业,并严重影响哥伦比亚迫切需要的复苏。

  2020年,油价暴跌,加上疫情对能源行业的冲击,导致哥伦比亚国内生产总值萎缩近7%,这是哥伦比亚有记录以来最严重的经济衰退。要知道,哥伦比亚十分依赖石油,即使在油价跌至负值、布伦特原油平均价格为41.96美元/桶的这一年,原油仍占该国财政收入的17%、出口收入的28%和GDP的3%。在2014年底油价暴跌之前,原油的经济重要性甚至更大。它创造了超过五分之一的政府收入,超过哥伦比亚出口总值的60%,几乎占GDP的5%。在石油行业复苏的带动下,哥伦比亚预计将在2021年实现强劲的经济反弹,国际货币基金组织和中央银行均预测其GDP增长将超过5%,但未来仍有很大的阻力。

  最紧迫的风险是新冠肺炎病例的急剧增加,以及哥伦比亚主要城市重新实行封锁措施,这将给本已脆弱的经济带来沉重压力。导致GDP增长速度、商业活动和税收收入下降,给陷入财政困境的国家政府带来更大压力。哥伦比亚财政部在2021年3月强调了其不稳定的财政状况,财政赤字达到了GDP的8.6%,这是有史以来的最高水平,超过了2020年报告的7.8%,要知道,当时GDP收缩了近7%。如果经济要复苏,资金短缺的哥伦比亚迫切需要通过吸引更多投资来重振能源部门。

  尽管政府和哥伦比亚峰值工业组织哥伦比亚石油协会(ACP )对石油工业的前景表示相当乐观,但数据却呈现出不同的画面。2021年1月,ACP预计每年的勘探和生产投资为31亿美元至34.5亿美元。虽然较2020年增长51%,但仍比2019年的40.3亿美元少5.8亿美元。油气产量低于需求,突显出石油行业尚未恢复疫情爆发前的运营水平。2021年2月,哥伦比亚的石油产量为745769桶/天,与2020年同期相比下降了15%,令人担忧。更令人担忧的是,正如贝克休斯的钻机数据所显示的那样,哥伦比亚油田的活动并没有以所需的速度增长。截至2021年3月底,哥伦比亚只有14台钻机在作业,而去年同期为25台,几乎是这个数字的两倍。

  这些数字表明,尽管政府实施了旨在促进石油公司投资的战略,包括通过退税或取消增值税来减轻税收,但支出仍未达到要求的水平。不断上升的财政压力,加上最新一轮封锁导致的经济活动下降,将迫使哥伦比亚减少支出,甚至可能减少石油行业的税收减免和其他激励措施。最近提出的税制改革,该国正寻求提高相当于GDP 1.5%的税收收入,这表明该国目前经济的状态十分萎靡,并透露出自2018年以来推出的许多企业税收优惠可能都会被削减甚至取消的讯号。如果这种情况发生,将阻止外国石油公司在已经动荡和高度不确定的经营环境中进一步投资。

  另一个正在出现的不利因素是,人们越来越怀疑新的大宗商品超级周期的说法。全球新冠肺炎病例增多、新一轮封锁以及疫苗推广缓慢,都在给全球经济带来压力,影响到金属和原油行业。据彭博社报道,投资者正在抛售大宗商品,尤其是金属产品,而且危机已经蔓延到原油板块。一个月前有关布伦特原油价格将逼近每桶80美元甚至100美元的说法很是令人怀疑。在2021年剩下的时间里,油价将会波动,尤其是现在欧佩克和其他国家已经表示将逐步取消减产,包括沙特阿拉伯每天100万桶的额外减产——这促使2021年1月油价上涨。增产将打压原油价格,尤其是如果美国和巴西等非欧佩克产油国继续增加石油产量的话。布伦特原油价格走弱对哥伦比亚构成了相当大的风险,因为该国境内的盈亏平衡价格较高,税后价格估计高达45美元/桶。

  值得一提的是,哥伦比亚生产的大部分石油都是含硫中质或重质原油,但自从IMO2020的引入以及全球持续大力降低燃料硫含量以来,这种原油越来越不受欢迎。南美有一些危险程度较低、保本价格较低的地区,这些地区生产的原油是轻质的,这让它们成为外国能源公司的首选目的地。从而使得哥伦比亚主要城市,特别是该国大部分油田所在的农村地区的不安,因为这些地区对外国石油生产商而言,风险更大。

  王佳晶 摘译自 今日油价

  原文如下:

  2021 Will Be Another Disastrous Year For Colombia’s Oil Industry

  The COVID-19 pandemic has hit Colombia and its economy, including the vital energy sector, particularly hard. After implementing one of the world’s longest pandemic lockdowns during 2020, which took the economy to the brink of collapse, a recent sharp spike in COVID-19 cases has forced the reintroduction of lockdown measures across the Andean country’s major cities. It is the popular tourist city of Medellin and Colombia’s all-important principal port Barranquilla which are the worst affected, with strict curfews and restrictions on movement now established. Those measures will impact many sectors of the economy including the vital petroleum industry and weigh heavily on Colombia’s desperately required recovery. During 2020, the oil price crash and COVID-19 pandemic sharply impacted the Andean country’s energy sector causing the gross domestic product to contract by almost (Spanish) 7%, Colombia’s worst economic decline on record. The strife-torn country’s dependence on crude oil becomes apparent when, even in a year where prices plunged into negative territory and Brent averaged $41.96 per barrel, it still accounted for 17% of fiscal revenue, 28% of export earnings, and 3% of GDP. Before the late-2014 oil price collapse, the economic importance of crude oil was even greater. It generated over a fifth of government revenue, more than 60% of Colombia’s exports by value, and almost 5% of GDP. While a strong economic rebound for Colombia is projected for 2021, led by a recovering petroleum industry, with the IMF and central bank both forecasting GDP growth of over 5%, there are significant headwinds ahead.

  The most pressing risk is the sharp uptick in COVID-19 cases and renewed lockdowns in Colombia’s major cities, which will weigh heavily on an already fragile economy. These will cause GDP growth, business activity, and tax revenue to decline placing greater pressure on a fiscally embattled national government. Bogota’s precarious finances are highlighted by Colombia’s finance ministry, in March 2021, raising the fiscal deficit to a startling 8.6% of GDP, its highest level ever and greater than the 7.8% deficit reported for 2020 when GDP contracted by nearly 7%. A cash-strapped Bogota urgently needs to reactivate the energy sector, by attracting additional investment, if the economy is to recover.

  While the Duque administration and Colombia’s peak industry body the Colombian Petroleum Association (ACP – Spanish initials) expressed considerable optimism regarding the petroleum industry’s outlook the numbers present a different picture. In January 2021, the ACP projected an annual exploration and production investment of $3.1 billion to $3.45 billion. While at the bottom end that represents a 51% increase over 2020, it is still at least $580 million shy of the $4.03 billion invested during 2019. Weaker than required hydrocarbon production highlights that the oil industry has yet to return to pre-pandemic operations. For February 2021, Colombia pumped 745,769 barrels per day, a worrying 15% decrease compared to the equivalent period for 2020, and similarly reported production volumes since the pandemic hit the Andean country. More worrying is that activity in Colombia’s oil patch, as shown by the Baker Hughes rig count, is not rising at the rate required. By the end of March 2021, there were only 14 drill rigs operating in Colombia compared to almost double that number, 25 drill rigs, for the same period a year earlier.

  Those numbers indicate that despite the Duque Administration implementing strategies aimed at boosting oil company investment, including tax relief through refunding or removing value-added tax, spending is falling short of the required levels. Rising fiscal pressures, combined with the declining economic activity caused by the latest round of lockdowns, will force Bogota to ease spending and potentially even the tax breaks and other incentives extended to the petroleum industry. Recently proposed tax reform, where the Duque administration is seeking to raise taxation revenue equivalent to 1.5% of GDP not only illustrates Bogota’s desperation but that many of the corporate tax benefits introduced since 2018 could be reduced or even removed. If that occurs it will deter further investment from foreign oil companies in what is already a volatile and highly uncertain operating environment.

  Another emerging headwind is the growing skepticism over claims of a new commodity supercycle. Rising COVID-19 cases and renewed lockdowns around the world along with sluggish vaccine rollouts are weighing on the global economic outlook impacting metals and crude oil. According to Bloomberg, investors are dumping commodities, notably metals, and the contagion has spread to crude oil, making proclamations from a month ago that Brent is headed to $80 or even $100 a barrel appearing doubtful. Oil prices will be volatile over the remainder of 2021, especially now that OPEC Plus countries have flagged the gradual unwinding of production cuts, including Saudi Arabia’s one million barrels per day, which triggered the January 2021 oil price rally. That will weigh on crude oil prices, particularly if major no-OPEC producers such as the U.S. and Brazil continue to bolster petroleum production. Weaker Brent pricing poses a considerable risk for Colombia because of its high onshore breakeven prices, which are estimated to be up to $45 per barrel after tax. Most of the petroleum produced in Colombia is comprised of sour medium to heavy grade crude oils, which are becoming increasingly less popular since the introduction of IMO2020 and the ongoing global push to substantially reduce the sulfur content of fuels. There are less hazardous jurisdictions with significantly lower breakeven prices in South America, which produce lighter sweeter grades of crude oil, making them superior destinations for foreign energy companies. Heightened insecurity in major cities and particularly the rural regions where much of Colombia’s oilfields are located poses a significant risk for foreign oil producers.