Serverless Architecture – Blog-1


What is Serverless computing?
The “serverless” bit doesn’t actually mean that there are no servers required to run the new feature. It just means that we don’t have to deal with the infrastructure.That means we don’t have to worry about scaling, multi-server communication and other problems related to distributed systems. Lambdas do everything for us!

Serverless can also mean applications where some amount of server-side logic is still written by the application developer but unlike traditional architectures is run in stateless compute containers that are event-triggered, ephemeral , and fully managed by a 3rd party.
These type of service has been previously described as ‘BaaS’ ‘Backend as a Service’.

When to use serverless:
-NO MORE SERVERS
-MANY USES
-LOW COST
-LESS CODE
-SCALABLE AND FLEXIBLE

In the below diagram the unit of work are getting smaller and smaller. we’ve gone from Monolithic -> Microservices -> Fuctions

serverless-blog (1)

Continue reading

Posted in Amazon, AWS, AWS Services, Microservices, Scala | Leave a comment

End of Add-ons & apps: Chrome & Firefox


cinfNow a days these two news are roaming around, and these are not only bad but very hard to digest. Lets get a glimpse of these news:

  •  Google will end support for Chrome apps on Windows, Mac, and Linux.
  •  Old Firefox Add-Ons Will Stop Working in Firefox 57, End of 2017.

For Chrome lets think about postman, so it includes postman as well? YES !! here is the migration link from postman

So, windows, macOS and Linux users will lose support for finding, installing and opening web apps installed from the Chrome Web Store over the next two years.

One thing to notice here, when you are on the web extension publishing page of chrome, they show an yellow background NOTE, Your extension will not be available for users other than chrome os users.

In mid 2017: Windows, macOS or Linux users will no longer be able to install any new apps. Apps that are already installed will continue to work. Chrome OS users will notice no change.

In starting of 2018: users will not be able to open the extensions.

Okay lets see why, Google says that only 1% of users use these apps so why to expend so much on support and management. another reason they state is that the regular web can now do the things that Chrome apps were built to do.

affecting chrome extensions? No.

It’s important to stress that Chrome extensions are not being discontinued. You can continue to find, install and use extensions.

If you are confused by chrome extension and chrome apps than:

Continue reading

Posted in Chrome, Chrome Extension, Knoldus Chrome Exntesion, Scala | Tagged , , , , | Leave a comment

Lightbend Monitoring: Lagom


Lightbend Monitoring provides insight into applications built with Lightbend technologies. It does so by instrumentation of frameworks like Akka and Lagom. The instrumentation is done by a Java agent (called Cinnamon) that runs when your application is starting up. It collects information in runtime based on the configurations that you have provided.

In this post, we would show the Circuit Breaker (CB) monitoring with Lagom. By default, Lagom enables CB for all the services. Circuit Breakers are used and configured on the client side, but the granularity and configuration identifiers are defined by the service provider. For more details on the Circuit breakers, read here.

circuit-breaker-states.png

In this post, we would try to setup a Lagom CB monitoring with Maven on a Java Project. For setting it up with sbt refer to this link.

First things first, the cinnamon agent is available from the Lightbend Commercial library, so you should have a commercial account with Lightbend.

  • In the .m2/settings.xml, you would have to add the server
  • <server>
     <id>lightbend-commercial</id>
     <username>d40ab051-XXXXXXXX-7b2cc62aa502@lightbend</username>
     <password>3cbebe2273745454666070f9d35b0f29bce779e1c</password>
     </server>
        
    
  • Next, add the Lightbend commercial repo
     <repositories>
          <repository>
              <id>lightbend-commercial</id>
              <name>Lightbend Commercial</name>
              <url>https://lightbend.bintray.com/commercial-releases</url>
          </repository>
    <repository>
          <id>lightbend-contrail</id>
          <name>Lightbend Contrail</name>
          <url>https://dl.bintray.com/typesafe/commercial-maven-releases</url>
        </repository>
  • Above 2 steps would ensure that you are able to download the commercial cinnamon agent from Lightbend.
  • Next, in the services that you would like to monitor, we would add the lagom dependencies

Continue reading

Posted in Microservices, Scala | Tagged , , , , | Leave a comment

Lagom Framework: The Legacy WordCount Example


What is Lagom?

Lagom is an open source micro-service framework, built with Akka message-driven runtime and Play web framework and finally light bend service orchestration. Mixing all these technologies abstracts away the complexities of building, running, and managing microservice architectures.

Lagom is a Swedish word meaning “just the right amount”.

Often, when people talk about microservices, they focus on the micro part of the name, assuming it means that a service should be small. We want to emphasize that the important thing when splitting a system into services is to find the right boundaries between services. This means aligning them with bounded contexts, business capabilities, and isolation requirements. A system of right-sized microservices will naturally achieve scalability and resilience requirements and be easy to deploy and manage. So, rather than focus on how small your services should be, design “Lagom” size services.

Lagom gives you two API to play with “Java” and “Scala

And two tools to work with “Maven” and “Sbt“.
Here in this article, we will build the wordcount example using the Scala language with Sbt build tool.

Little Bit About lagom Architecture: –

Lagom is a framework for creating microservice-based systems. It offers four main features:

  1. Service API
  2. Persistence API
  3. Development Environment
  4. Production Environment

Continue reading

Posted in big data, Microservices, Scala | Tagged , , , , | Leave a comment

Official: Knoldus Blog Chrome Extension


As we can see below, now no need to worry about searching the globe to get the exact information, solution to your tech. query, latest technologies intros or tricks etc,.. All you have to do is to just click the extension, write your search, click the search button and BOOM !!

Knoldus_Chrome_Extension

Knoldus Blogs: Chrome Extension

Every thing will be on your finger tips, you will be redirected to the Knoldus blog where hundreds of well written posts with examples are available so you can learn as much as you can. lets see how.

You search for “object oriented JavaScript” click search button and redirected to Knoldus blog with the related blogs. isn’t it amazing ?

Continue reading

Posted in Chrome, Chrome Extension, Knoldus Chrome Exntesion, Scala | Tagged , , , , , | Leave a comment

Scala Trait and Mixin – Points to Remember


  • Trait can be viewed not only as interfaces in other languages, but also as classes with only parameterless constructor.
  • Whenever there is some code in trait, the trait is called mixin.
    	trait Alarm {
    		def trigger(): String
    	}
    
  • In scala trait, If we create simple class and pass parameter in constructor, without any val or var, it means, that scope of variable is within constructor only, if we specify val or var, it means, the compile create getter for variables.
  • If one trait have variable and not initialize with some value, then when we mix with some class, we need to declare that variable in primary constructor with val or var or override in scala otherwise we are getting compile time error.
    error: class V3 needs to be abstract, since value messages in trait V of type String is not defined
    
  • When we create some variable in trait, it defines as abstract method in byte-code because scala have same name space for variables and method.
  • In class perspective, trait have to implement all their methods and have only one constructor that does not accept any parameter.
  • A trait can extend class also (abstract or concrete).
  • If some trait is mixed with some class during composing like new class with trait , and that trait extends some class like trait extends SomeClass , this means, compiler will expect that the class must be the subclass of SomeClass otherwise we got compile time error.
    Continue reading
Posted in Best Practices, Functional Programming, Scala | Tagged , , , , , , , , , , , , , | Leave a comment

Knolx – Akka Finite State Machine


Hi all,

Knoldus has organized a 30 min session on 17th February 2017 at 4:05 PM. The topic was Akka Finite State Machine. Many people have joined and enjoyed the session. I am going to share the slides and Video here. Please let me know if you have any question related to linked slides.


KNOLDUS-advt-sticker

Posted in Akka, Scala | Tagged , , , , , , , , | Leave a comment

How to setup Envconsul for dynamic configuration in your application(or services).


So, You want to integrate Envconsul into your application for dynamic configuration.Let’s see How it can be achieved and what all needs to be done.

Using Envconsul you can have the dynamic configuration in your services without taking them down i.e Services will never go down and you can make changes in your services(dynamic configuration).You can change things like the PORT number of any service, db password, access keys and IP address on runtime and You don’t have to worry about the service downtime.

Step1. The very first job would be to setup Consul. In consul, we will be dealing with Consul KV store to allow to define KV(Key Value) pairs that can be pulled into running services.Let’s see How we can setup Consul and then add KV pairs into Consul KV store.

1. First, install the consul from here https://www.consul.io/intro/getting-started/install.html
2. Run the Consul Agent using this command “consul agent -dev”
3. Then add KV pairs into Consul KV store using the following commands

consul kv put redis/config/minconns 1

//where redis/config is the folder and minconns is the key and 1 is the value for the key minconns.

For more information check here https://www.consul.io/intro/getting-started/kv.html

Now our Consul has been setup, Now You can check the KV pairs and running services at

http://localhost:8500

For KV pair visit

http://localhost:8500/ui/#/dc1/kv/

Step2. Setup Envconsul
Envconsul is a tool which is basically used to read and set environmental variables for processes from Consul.Envconsul provides a convenient way to populate values from Consul into a child process environment using the envconsul daemon.
The daemon envconsul allows applications to be configured with environment variables, without having knowledge about the existence of Consul. This makes it especially easy to configure applications throughout all your environments: development, testing, production, etc.

Now you can download the Envconsul from here https://releases.hashicorp.com/envconsul/

Once the envconsul is downloaded unzip it and put it in the /usr/local/bin. It is the same path where we put consul at.

Now both Consul and Envconsul are setup.

Step3. Access Environment variables set by envconsul into the application.
I am using Java.So, There are basically two ways in Java.

1.The java.lang.System.getenv(String name) method gets the value of the specified environment variable. An environment variable is a system-dependent external named value.

For Example
String value = System.getenv(“TEST”); //where TEST is the key and we are trying to fetch the value of key “TEST” over here.

2.Another way is to access the environment variables through application.conf.

In application.conf do the following
test = test
test = ${?TEST}//TEST is an environment variable.

After this you can access the test variable in your application like below

String testEnvVariable = ConfigFactory.load().getString("test");

Step4. Now finally we will run our application using envconsul like below

$envconsul -prefix=Test env mvn lagom:runAll

// Test is the folder where all the key value pairs reside and env is where all the environment variables reside and mvn lagom:runAll is the way to run my application

Now, You are done and everthing is in its place. To check everything works fine and we are able to make dynamic configuration, You can make changes to Consul’s KV store values and see if the updated values are reflected in your application while it is running,If it does you have achieved it cheers!
If the updated values do not reflect into the running application then you might have to go back to previous steps and ensure everything is correct and configured properly. That’s it!

If you find any challenge, Do let me know in the comments.
If you enjoyed this post, I’d be very grateful if you’d help it spread.Keep smiling, Keep coding! Cheers!

Posted in Scala | Leave a comment

Knolx – Intoduction to AWS IAM


Hi all,

Knoldus has organized a 30 min session on 3rd March 2017 at 4:50 PM. The topic was Introduction to AWS IAM. Many people have joined and enjoyed the session. I am going to share the slides here. Please let me know if you have any question related to linked slides.

 

 

Posted in Amazon, AWS, Cloud, Scala, Security, Security Controls | Leave a comment

Jenkins – Integrating Email Service


Jenkins is one open source tool to perform continuous integration and build automation. Using it, all development work can be integrated as early as possible. The resulting artifacts are automatically created and tested and as a result the process of identification of errors becomes faster. But there must be a way so that build status and testing results can be reported to the team. And then email service come into picture.

To dig further into the details of jenkins and building jobs in it, you can refer to Introduction to Jenkins and Building Jobs with Jenkins.

Now the next question comes i.e “ How email service can be integrated with Jenkins? ”

So I will be discussing two approaches to configure email service:

1) Default Email Notifier: This is what comes default with Jenkins. It contains a default message containing the Build number and its status.

2) Email Extension Plugin: This plugin allows you to configure every aspect of email notifications. You can customize when an email is sent, who should receive it, and what the email says.

Next step will be, what all configurations we require to use the above two.

Continue reading

Posted in testing, Tutorial | Tagged | Leave a comment