Friday, October 5, 2018

Billing and TCO calculator on AWS

Billing and TCO calculator on AWS
Sometimes it is very hard to predict on AWS all the costs of our service.

In my opinion, the TCO calculator is too easy and not complex and it does not allow to calculate useful ideas :-(

Useful sites:







Docker images on AWS

Docker images on AWS


At the very begining we should create docker image from dockerfile...

The docker container with 3 main "beasts": Java, Tomcat and Alpine/Centos Linux... - very useful information we can read at:
https://dzone.com/articles/performance-patterns-in-microservices-based-integr-1


Amazon Elastic Container Service (ECS) or on Fargate cluster...


Amazon Elastic Container Service (ECS) is a highly scalable, high performance container management service that supports Docker containers and allows you to easily run applications on a managed cluster of Amazon EC2 instances. Amazon ECS eliminates the need for you to install, operate, and scale your own cluster management infrastructure. With simple API calls, you can launch and stop container-enabled applications, query the complete state of your cluster, and access many familiar features like security groups, Elastic Load Balancing, EBS volumes and IAM roles. You can use Amazon ECS to schedule the placement of containers across your cluster based on your resource needs and availability requirements. You can also integrate your own scheduler or third-party schedulers to meet business or application specific requirements.

Spring Boot App

Spring Boot App




Spring Boot is Spring's "convention-over-configuration" solution for creating stand-alone, production-grade Spring-based Applications that you can "just run".

It is preconfigured with the Spring's "opinionated view" of the best configuration and use of the Spring platform and third-party libraries so you can get started with minimum fuss. 
Most Spring Boot applications need very little Spring configuration...

See more at:

FARGATE cluster on AWS

FARGATE cluster on AWS

AWS Fargate is a compute engine for Amazon ECS that allows you to run containers without having to manage servers or clusters. With AWS Fargate, you no longer have to provision, configure, and scale clusters of virtual machines to run containers as Docker with Tomcat and Java...

But pay attention with billing with Fargate on AWS!

Fargate cluster doubles costs, because it is cluster (e.g. two "legs"/nodes):


Example:
vCPU = $0,05 per hour * 700 hours (25 days) * 2 nodesOfCluster = $70 per 1 month (25 days) = $70

Sharding in the Blockchain

Sharding in the Blockchain


Sharding is a relatively new concept in the Blockchain.

Sharding: a solution to the scalability, latency and transaction throughput issues. 
Sharding is a concept that's widely used in databases, to make them more efficient. 

In case of the blockchain, each node will have only a part of the data on the blockchain, and not the entire information, when sharding is implemented.

A blockchain (https://en.wikipedia.org/wiki/Blockchain), originally block chain, is a growing list of records, called blocks, which are linked using cryptography.
Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data (generally represented as a merkle tree root hash).

In cryptography and computer science, a hash tree or Merkle tree is a tree in which every leaf node is labelled with the hash of a data block, and every non-leaf node is labelled with the cryptographic hash of the labels of its child nodes.

By design, a blockchain is resistant to modification of the data. It is "an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way". For use as a distributed ledger, a blockchain is typically managed by a peer-to-peer network collectively adhering to a protocol for inter-node communication and validating new blocks. Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority. 

See more about implementations of blockchain in Java:

LinkedBlockingQueue vs ConcurrentLinkedQueue

LinkedBlockingQueue vs. ConcurrentLinkedQueue


Why and when do we use Blocking Queues and Non Blocking Queues with working with streams and media? Unbounded or not? What is when the best choice?

Once upon a time, in a galaxy far, far away, there was a beautiful young Queue...  :-)



Following operations are allowed e.g.:

bqueue.take() to take form a stream...

What are the advantages/disadvantages of unbounded queue?
With an unbounded queue, a producers can get far ahead of the consumers. Pay attention for OutOfMemoryError! How can we signal a producer that the queue is full?

ASPECTS:




  • speed
  • concurrency 
  • time to access last element
  • blocking
  • unbounded

LinkedBlockingQueue

LinkedBlockingQueue is a good choice for many pools (depending on the pool management strategy):
https://www.geeksforgeeks.org/linkedblockingqueue-class-in-java/
https://www.geeksforgeeks.org/java-8-linkedblockingqueue-spliterator-method-with-examples/

The LinkedBlockingQueue is an optionally-bounded blocking queue based on linked nodes. It means that the LinkedBlockingQueue can be bounded, if its capacity is given, else the LinkedBlockingQueue will be unbounded. The capacity can be given as a parameter to the constructor of LinkedBlockingQueue.

This queue orders elements FIFO (first-in-first-out). It means that the head of this queue is the oldest element of the elements present in this queue. The tail of this queue is the newest element of the elements of this queue. The newly inserted elements are always inserted at the tail of the queue, and the queue retrieval operations obtain elements at the head of the queue. Linked queues typically have higher throughput than array-based queues but less predictable performance in most concurrent applications.

ConcurrentLinkedQueue

The ConcurrentLinkedQueue is good as well in many cases:
 https://www.javacodex.com/Concurrency/ConcurrentLinkedQueue-Example

ConcurrentLinkedQueue is an unbounded thread-safe queue based on linked nodes. This queue orders elements as a FIFO (first-in-first-out). The head of the queue is that element that has been on the queue the longest time. The tail of the queue is that element that has been on the queue the shortest time. New elements are inserted at the tail of the queue, and the queue retrieval operations obtain elements at the head of the queue.

A ConcurrentLinkedQueue is a good choice when many threads share access to a common collection. Like most other concurrent collection implementations, this class does not permit the use of null elements.


A limited capacity of BlockingQueue 

(https://www.javacodex.com/Concurrency/BlockingQueueExample) is also helpful if you want to throttle some sort of request.

Useful sites to learn it deeper:

https://www.javacodex.com/Concurrency/

https://dzone.com/articles/a-specialized-high-performance-concurrent-queue







Microservices on Amazon AWS

Microservices on Amazon AWS


Microservices are an architectural and organizational approach to software development where software is composed of small independent services that communicate over well-defined APIs. These services are owned by small, self-contained teams.

Microservices architectures make applications easier to scale and faster to develop, enabling innovation and accelerating time-to-market for new features.

Useful page:
https://aws.amazon.com/microservices/

We need to have or create an account on AWS to try building the Microservices on AWS...:
https://aws.amazon.com/
AWS Accounts Include 12 Months of Free Tier Access.