Tuesday, January 31, 2017

In the previous posts, we talked about public cloud offerings. This leads us to compare public clouds. Let us do so today with comparision of private network offerings.

Azure started offering virtual networks from 2013 while AWS has been an early starter.  Azure's Virtual Network VN resembles AWS VPC in many aspects but we will also enumerate differences. That said Azure has kicked it up a notch.

Subnets:
Subnets divide the network into smaller network and are very helpful to create private networks. AWS allows VPC to be created with
1) single public subnet
2) public and private subnets
3) public and private subnets with hardware VPN access
4) private subnet only with a hardware VPN access.
Azure also gives similar flexibility to create subnets of any size. The difference is in the use of wizards between AWS and Azure.  AWS wizards have been used for a while longer.

Security:
Security is one of the most important considerations for the virtual private network. AWS provides security services to tackle at instance level, subnet level and overall network.  Azure has simpler design. Inbound and outbound rules can be configured in both.

Security Groups:
AWS security groups helps control access and this is available from both. Azure calls it Network Security Group and it is available only for regional virtual networks. 

Network ACLs:
Azure and AWS both support network ACLs which allow users to selectively permit or deny traffic to your networks.

Custom routing tables.
subnets inherit the main routing table. In AWS, we can customize these within a subnet.In Azure, the support was somewhat limited until recently.

Virtual network interfaces
multiple NICs are allowed to be activated on virtual machine instances however both cloud providers only allow this on large instances.
documentation on Azure: https://docs.microsoft.com/en-us/azure/
documentation on AWS: https://aws.amazon.com/documentation/ 

#codingexercise
int GetMinSumSquares(List<int>positives, uint scalar)
{
if (positives == null || positives.Count == 0) return 0;
int inclusive = positives[0];
int exclusive = 0;
for (int i = 1; i < positives.Count; i++)
{
var min = Math.min(inclusive, exclusive);
inclusive  = exclusive + positives[i] × positives[i];
exclusive = min;
}
return Math.min(inclusive, exclusive);
}
Given an integer array of n integers, find sum of bit differences in all pairs that can be formed from array elements
For example bit difference for 2 represented by 010 and 7 represented by 111 is 2. Therefore an array with {2,7} will have (2,2), (2,7), (7,2) and (7,7) with sum of bit differences = 0 + 2 + 2 + 0 = 4.
int GetSumBitDifferences(List<int> A)
{
int ret = 0;
for (int i = 0; i < 32; i++)
{
int count = 0;
for (int j = 0; j < A.Count; j++)
     if (A[j] & (1 << i))
         count++;

ret += (count x (A.Count-count) x 2);
}
return ret;
}
Another way to do this would be to enumerate all combinations of pairs from the array using the Combine method discussed earlier
int GetSumBitDifferencesUsingCombinations(List<int> A)
{
int ret = 0;
var pairs = new List<Tuple<int,int>>();
var seq = new List<int>();
int start = 0;
int level = 0;
Combine(pairs, ref seq, ref pairs, start, level);
pairs.ForEach ( x => ret += GetDiff(x.first, x.second));
return ret;
}
The combinations above also include those where the first and second element are the same however there is no contribution to the result

No comments:

Post a Comment