Saturday, June 3, 2017

We talked about the overall design of an online shopping store that can scale starting with our post here. Then we proceeded to discussing data infrastructure and data security in a system design case in previous posts. We started looking at a very specialized but increasingly popular analytics framework and Big Data to use with data sources. For example, Spark and Hadoop can be offered as a fully managed cloud offering. we continued looking at some more specialized infrastructure including dedicated private cloud. Today we add serverless computing to the mix.
Serverless computing is about Backend as a service as well as Function as a service. A Backend as a service isone which allows a portion of the backend activities to be expressed as functions that execute elsewhere on container. These can be both synchronous and asynchronous. This allows the backend services to be lighter. It can involve any number of operations  and as granular as appropriate. A Function as a Service allows the fat client and single page applications to be lighter as the don't necessarily have to do all the computations in one page. They can be broken down into functions that evaluate elsewhere. In a model-view-controller architecture, we had multi-page applications but these allow super efficient and rich single page applications.
In the case of the store, the functions may be listed as follows:
1) Authentication function - Most authentication mechanism is universal and consolidated for the application to allow users to sign into membership providers. These can be offloaded to their own functions instead of being performed by the same server that responds to shopping experience.
2) The database access - Much of the data is in the form of relational data that requires the same amount of data translations but they need not be done in the server and can be fine granular .
3) MVC becomes a single page again. As discussed, the front-end allows single page applications to be composed of hundreds of smaller functions when appropriate.
4) Search Function - Some of the methods such as search are orthogonal to the shopping experience but equally important. Therefore they can be offloaded.
5) Purchase Function - This is probably the most used function but it is almost independent of the user or the products since it involves card activity. Consequently it is a separate function in intself.
Not just functions but messages can also be translated. Functions can be queued with Kafka.
Thus functions instead of modules become an appealing design.
#codingexercise
int IndexOfUnusedInUnordered(unordered, item, ref h, ref used)
{
assert(h.Contains(item));
int index = unordered.IndexOf(item 0);
while (index != -1 && used[index] != true && index < unordered.Count)
{
if (used[index] != true){
    used[index] = true;
    h[item] -= 1;
    break;
 }
index = unordered.IndexOf(item, index+1);
}
return index;
}

No comments:

Post a Comment