Saturday, June 29, 2024

AWS Lambda

What is Serverless : 

 Pay for what you use

Service automatically scales up or down accordingly. 



AWS Lambda allows upload the code to Amazon aws without the need of the server. 

AWS Lambda is a Function as a service (FaaS) which is a serverless architecture that developers can use to write custom backend functions and deploy the function code directly to the cloud infrastructure

It falls under the Compute services in AWS. 

Process :

1. Create a lambda function

2. Uplaod to AWS 

3. Test and trigger

Lambda execution models:

1. Synchronous 

2. Aysnchronous

3. Pull stream based





Monday, June 3, 2024

AWS Certified Cloud Practitioner Exam CLF-C02

Cloud Concepts - 24%

Security and Compliance - 30%

Cloud Technology and Services - 34%

Billing, Pricing and Support - 12%


Monday, May 13, 2024

AWS Storage

 1. S3 (Simple Storage Service) - File storage

2. Glacier

3. CloundFront

4. EBS (Elastic Block Stoarge) - Block storage

5. Storage Gateway

6. Snow Family

7. Databases


S3 Storage Class:

It is all about Object Storage through buckets. Objects could be a file or any chunk of data. AWS stores them and makes available to at least 3 available zones. 

Supports Encryption.

Ways to get data into S3 buckets:

1. Through API

2. AWS Direct Connect

3. Storage Gateway

4. Kinesis Firehose

5. Transfer Acceleration

6. Snowball, snowball edge and snowmobile


S3 Concepts:

1. Bucket

2. Regions

3. Objects

4. Keys

5. Object URLs

6. Eventual Consistency

7. Prefixes and Delimiters


Operations on S3:

1. Creating and deleting buckets

2. Reading objects

3. Writing objects

4. Deleting objects







AWS Compute

 1. EC2

2. Lambda

3. Batch

4. Serverless Application Repository

5. AWS Outposts

6. AWS App Runner


Cloud Computing and AWS

Internet-based solution which operates on other servers. We don't have details about the server infrastructure details. On-premise system piloted on other servers. 

Examples: Google Drive, Dropbox

Benefits:
  1. Cost reduced due to hardware sharing, operationa cost reduction as no one particularly managing physical servers and reduced deployment cost.
  2. Increased Resiliency, Performance and capacity (storage)


Models

Hybrid
IAAS (Infrastructure as a service) 
PAAS  (Platform as a service) - like webhosting
SAAS (Software as a service) - Email application like gmail 


 Players
 1. AWS 
  2. Azure 
  3. GCP


AWS History:
AWS launched first time with SQS in 2004.
2006 - EC2, S3 buckets
2007 - Simple DB solution
2008 - Elastic IP 
2009 - Management Console and VPC
2010 - Route 53, SNS, IAM
2011 - Elastic Cache
2012 - Dynamo DB
2013 - Kinesis and lots of new features
2014 - Redshift and 560 new features
2015 - CloudTrail and 720 new features


AWS Core Foundation elements:
Compute
Storage
Database
Network
Security 


Compute
1. EC2
2. Elastic Beanstalk
3. Lambda
4. Elastic Containers

Storage:
1. S3 - Storage of data in small chunks called Buckets
2. Glacier - used for archival purposes
3. Storage gateway

Databases:
1. Dynamo DB - NoSQL
2. ElasticCache - Fast retrieval
3. Redshift 
4. SnowBall

Network:
1. VPC
2. CloudFront
3 Route53 - DNS
4. ApiGateway

Management 
1. Cloud Watch
2. Cloud Formation
3. Cloud Trail
4. AutoScale

Media Services
1. Kinesis video streams

Machine Learning
1. Rekognition

Analtics



AWS Products Overview:


Security, Identity and Compliance:
IAM
Cognito
Cloud HSM
WAF and Shied

AWS Cost Management:


Mobile Services:
Mobile Hub

Application Integration:
SQS - handle application process
SNS - Getting notification

IOT




Regions and Availabilities:

Wednesday, January 11, 2023

AWS Cloud Watch

 using Amazon.CloudWatchLogs;

using Amazon.CloudWatchLogs.Model;

using Amazon.Runtime;

using API_Infrastructure.DBHelpers;

using API_Infrastructure.Interfaces;

using API_Models.dbModels;

using System;

using System.Collections.Generic;

using System.Configuration;

using System.Linq;

using System.Threading.Tasks;


namespace API_Infrastructure.Helper

{

    public class CloudWatcherLogger

    {

        private string LogMode;

        private string LogGroupName;

        private AmazonCloudWatchLogsClient LogClient;

        private string _nextSequenceToken = null;

        private string _logStream;

        private string accessKey = ConfigurationManager.AppSettings["AccessKey"];

        private string secretKey = ConfigurationManager.AppSettings["SecretKey"];

        private string regionName = ConfigurationManager.AppSettings["RegionName"];


        public CloudWatcherLogger()

        {

            this.LogMode = ConfigurationManager.AppSettings["LogMode"] ?? "DB";

            this.LogGroupName = ConfigurationManager.AppSettings["LogGroupName"] ?? "/development/opensparkz/logs";

            this.LogClient = new AmazonCloudWatchLogsClient();

        }



        public static CloudWatcherLogger GetLogger()

        {

            var logger = new CloudWatcherLogger();


            // Create a log group for our logger

            logger.CreateLogGroup();


            // Create a log stream

            logger.CreateLogStream();


            return logger;

        }



        /// <summary>

        /// Logs the data into cloud watch.

        /// </summary>

        /// <param name="json">String json to log.</param>

        public async Task LogData(string json)

        {

            try

            {

                var response = await this.LogClient.PutLogEventsAsync(new PutLogEventsRequest()

                {

                    LogGroupName = this.LogGroupName,

                    LogStreamName = _logStream,

                    LogEvents = new List<InputLogEvent>()

                                {

                                    new InputLogEvent()

                                    {

                                        Message = json,

                                        Timestamp = DateTime.UtcNow

                                    }

                                },

                    SequenceToken = _nextSequenceToken

                });


                this._nextSequenceToken = response.NextSequenceToken;

            }

            catch (Exception)

            {

            }

        }


        private void CreateLogStream()

        {

            this._logStream = DateTime.UtcNow.ToString("yyyyMMddHHmmssfff");

            this.LogClient.CreateLogStream(new CreateLogStreamRequest(this.LogGroupName, this._logStream));

        }


        private void CreateLogGroup()

        {

            try

            {

                var existing = this.LogClient.DescribeLogGroups(new DescribeLogGroupsRequest() { LogGroupNamePrefix = this.LogGroupName });

                var logGroupExists = existing.LogGroups.Any(l => l.LogGroupName == this.LogGroupName);

                if (!logGroupExists)

                    this.LogClient.CreateLogGroup(new CreateLogGroupRequest(this.LogGroupName));

            }

            catch (Exception ex)

            {

                throw ex;

            }

        }

    }

}

Wednesday, October 5, 2022

Task Parallel Library in .NET C#

 TPL  (Task Parallel Library) is a set of classes which helps developers to add parallelism and concurrency to the code. It leverages all the available processes to use efficiently by the code. 

Using TPL, you can optimize the performance of the code by dividing the workload. In the developer jargon, it is a way to utilize multithreading. Using TPL, multithreading becomes easier. Otherwise you need to take care of resource utilization and other parameters in order to achieve multithreading by yourself.