We continue with the discussion on Airbnb data architectures and store services. We were reviewing Payment Systems from Airbnb. Airbnb is a global online marketplace where payments are one of the largest in-house payment systems. They had three standalone systems - a backend billing API, a payment gateway to external processors, and a financial pipeline for Spark based financial reporting. Billing interface allowed addition of items other than the usual reservation and payment which includes reservation nights, fees, taxes, photography costs, coupons by representing them with abstract data models and attributes. The checkout flow now becomes general to all items and streamlined while publishing events to all interested subscribers.
The billing interface generates a series of platform events in a consistent schema which is distributed to processors via the Kafka message bus.The payment gateway provides a unified API that supports forward and backward transactions to and from the processors. With the unified API, a new payment model for a local or country specific payment method can be easily added and integrated.
The financial data pipeline is built on Spark and Scala. It tracks receivables, payables, revenues and taxes and how funds are transferred between these accounts. By the very nature of the funds involved, the bookkeeping is all double-entry where the amounts entering or exiting are all tallied. The events are converted into accounting information and then filtered into different accounts such as receivables, liabilities and revenue etc.
It should stand out that the rearchitecture emphasized a governance based model on the data architecture. The financial data pipeline was intended for an audience comprising of regulators, local governments and Airbnb investors. It is not customer centric or data warehouse. In other words events are not processed to update customer and billing in the billing backend. Also the data is not flowing into a warehouse where analysis from operational data could improve business intelligence with its own stack. This means that additional services can now be written as their own microservice. For example, a rewards service or a stored value service can be written behind the payment gateway. Also a payment routing service to route the payments through one or more external processors also can also be written as a microservice. Some microservices can be pure compute as those pertaining to storage such as customer and balances may be handled with storage APIs The second thing to observe is the separation between operational and reporting architecture. Events are generated from the operational side only and consumed by the reporting side only. An alternate way would be to use the data warehouse ingestion capabilities.
#codingexercise
public int maxProduct(List<int> input)
{
int lo = 1;
int hi = 1;
int result = 1;
for (int i = 0; i < input.Count; i++)
{
if (input[i] == 0)
{
lo = 1;
hi = 1;
}
else{
int temp = hi * input[i];
if (input[i] > 0)
{
hi = temp;
lo = Math.Min(lo * input[i], 1);
}
else
{
lo = temp;
hi = Math.Max(lo * input[i], 1);
}
}
if (result < hi)
result = hi;
}
return result;
}
The method can take a parameter for the size of the desired subset.
public int maxProductSubsetSum(List<int>input)
{
input.Sort();
int i = 0;
int j = input.Count - 1;
int product = 1;
while ( i < j )
{
// greedily take the next element or pair of elements for a product
to increase product
// increment i and decrement j depending on the choice above;
}
return product;
}
The billing interface generates a series of platform events in a consistent schema which is distributed to processors via the Kafka message bus.The payment gateway provides a unified API that supports forward and backward transactions to and from the processors. With the unified API, a new payment model for a local or country specific payment method can be easily added and integrated.
The financial data pipeline is built on Spark and Scala. It tracks receivables, payables, revenues and taxes and how funds are transferred between these accounts. By the very nature of the funds involved, the bookkeeping is all double-entry where the amounts entering or exiting are all tallied. The events are converted into accounting information and then filtered into different accounts such as receivables, liabilities and revenue etc.
It should stand out that the rearchitecture emphasized a governance based model on the data architecture. The financial data pipeline was intended for an audience comprising of regulators, local governments and Airbnb investors. It is not customer centric or data warehouse. In other words events are not processed to update customer and billing in the billing backend. Also the data is not flowing into a warehouse where analysis from operational data could improve business intelligence with its own stack. This means that additional services can now be written as their own microservice. For example, a rewards service or a stored value service can be written behind the payment gateway. Also a payment routing service to route the payments through one or more external processors also can also be written as a microservice. Some microservices can be pure compute as those pertaining to storage such as customer and balances may be handled with storage APIs The second thing to observe is the separation between operational and reporting architecture. Events are generated from the operational side only and consumed by the reporting side only. An alternate way would be to use the data warehouse ingestion capabilities.
#codingexercise
public int maxProduct(List<int> input)
{
int lo = 1;
int hi = 1;
int result = 1;
for (int i = 0; i < input.Count; i++)
{
if (input[i] == 0)
{
lo = 1;
hi = 1;
}
else{
int temp = hi * input[i];
if (input[i] > 0)
{
hi = temp;
lo = Math.Min(lo * input[i], 1);
}
else
{
lo = temp;
hi = Math.Max(lo * input[i], 1);
}
}
if (result < hi)
result = hi;
}
return result;
}
The method can take a parameter for the size of the desired subset.
public int maxProductSubsetSum(List<int>input)
{
input.Sort();
int i = 0;
int j = input.Count - 1;
int product = 1;
while ( i < j )
{
// greedily take the next element or pair of elements for a product
to increase product
// increment i and decrement j depending on the choice above;
}
return product;
}
No comments:
Post a Comment