$30 off During Our Annual Pro Sale. View Details »

Getting Started with Microservices

Getting Started with Microservices

Understand:
1. Why Microservice ?
2. What is Microservice ?
3. What do we( Developer,Architect, Business..etc) need ?
4. Technology Comparison
5. Microservice Features
6. Spring Boot Features
7. Microservice Communication
8. Testing

Walking Tree Technologies

November 24, 2016
Tweet

More Decks by Walking Tree Technologies

Other Decks in Technology

Transcript

  1. Getting Started With
    Microservices
    Pranav Kumar

    View Slide

  2. Agenda
    ● Why Microservice ?
    ● What is Microservice ?
    ● What do we( Developer,Architect, Business..etc) need ?
    ● Technology Comparison
    ● Microservice Features
    ● Spring Boot Features
    ● Microservice Communication
    ● Testing
    ● Demo

    View Slide

  3. Why ?

    View Slide

  4. Problem with Monolithic Architecture
    ➔ Tightly Coupled
    ➔ Language dependency
    ➔ Scalability
    ➔ Root Cause Analysis
    ➔ Monitoring
    ➔ Auditing
    ➔ Performance
    Management
    Integration Layer (Business Logic)
    Catalog
    Query
    Parts
    Pricing &
    Availabilit
    y
    Quotatio
    n
    Order
    Order
    Track
    ORM
    Database
    Pricing

    View Slide

  5. What ?
    ➔ Software Architecture Style
    ➔ Loosely coupled
    ➔ Language Agnostic
    ➔ Highly Scalable
    Catalog
    ORM
    Database

    View Slide

  6. What ?
    “Microservices is a way of breaking large software projects into smaller,
    independent, and loosely coupled modules. Individual modules are
    responsible for highly defined and discrete tasks and communicate with other
    modules through simple, universally accessible APIs.”

    View Slide

  7. What do we need ?

    View Slide

  8. Software/Service
    ● Loosely coupled
    ● Rest Support
    ● Transaction Management
    ● Log Management
    ● Auditing
    ● Scalable
    ● Secure
    ● Statistics
    We need..

    View Slide

  9. Technologies.. Comparison
    Rest
    Support
    Embedded
    Container
    Statistics
    Support
    Log
    Management Transaction Management Security
    DropWizard
    ✓ ✓ ✓ ✓
    ✕ ✓
    Spring Boot ✓ ✓ ✓ ✓ ✓ ✓
    Apache Karaf ✓ ✓ ✕ ✕ ✓ ✓
    Jersey ✓ ✓ ✓ ✓ ✕

    Apache CXF ✓ ✓ ✓ ✓ ✓ ✓

    View Slide

  10. Microservice Features

    View Slide

  11. Coupling
    Microservices definitions says that
    “Microservices is a way of breaking
    large software projects into smaller,
    independent, and loosely coupled
    modules”
    So, this issue is straightaway solved.
    Catalog
    ORM
    Database
    Query Parts
    ORM
    Database

    View Slide

  12. Language Independent
    Each service can be developed
    using different programming
    language
    Allows you to take advantage of
    emerging and latest technologies
    (framework, programming
    language , programming practice,
    etc.).
    Catalog( Spring Boot )
    Spring Data
    NoSql
    Query Parts( Apache Karaf )
    Hibernate
    RDBMS

    View Slide

  13. Scalability
    Since microservices are very small part of the complete software ecosystem, It
    is very easy to scale the same.
    Unlike, the monolithic web application, where if we have to do a scaling, first
    we have to setup the environment ( apache, tomcat ) and then deploy the
    war/ear files in that.

    View Slide

  14. Scalability with monolithic ...
    Integration Layer (Business Logic)
    Catalog
    Query
    Parts
    Pricing
    &
    Availabi
    lity
    Quotat
    ion
    Order
    Order
    Track
    ORM
    Database
    Pricing
    Integration Layer (Business Logic)
    Catalog
    Query
    Parts
    Pricing
    &
    Availabi
    lity
    Quotat
    ion
    Order
    Order
    Track
    ORM
    Database

    View Slide

  15. Scalability with Microservice
    Catalog
    ORM
    Database
    Query Parts
    ORM
    Database
    Catalog
    ORM
    Database

    View Slide

  16. Root Cause Analysis
    It is always difficult to find the root cause in a Single Large Monolithic system.
    In microservice, fault isolation would be improved and we can easily identify
    which service is consuming more memory or cpu and we can scale that
    service easily and fix the issue ( if any ) later.

    View Slide

  17. Spring Boot

    View Slide

  18. Logging Strategy
    Spring Boot provides us the various way to achieve logging
    ➔ Using Aspect
    ➔ Using logback
    ➔ Annotation based logging ( When an exception occurs )

    View Slide

  19. @Before("execution(* com.wtc.samplems.controller.*.*(..))")
    public void logServicebefore(JoinPoint joinPoint) {
    logger.debug("Completed: " + joinPoint);
    System.out.println( "Completed: " + joinPoint );
    }
    Annotation ( Handling Exception and log ):
    @ExceptionHandler(Exception.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public @ResponseBody JSONObject handleException(Exception e,
    HttpServletRequest request) {
    JSONObject jSONObject = new JSONObject();
    jSONObject.put(ConstantsUtility.STATUS, ConstantsUtility.FAILED);
    UtilityLogger.error("Request Processing Failed in Navigation Serv
    "+e.getMessage());
    return jSONObject;
    }
    AspectJ:

    View Slide








  20. UTF-8
    ./logs/servive.log

    %d ${logger.type} %p %m%n


    10
    ./logs/navigationservices.log.%i


    1MB




    %d ${logger.type} %p %m%n
    utf8






    Logback:

    View Slide

  21. Monitoring
    Spring boot comes with it’s own monitoring tool called “Spring Admin Console”
    We can monitor various aspects like:
    ➔ Application health
    ➔ Memory
    ➔ JVM
    ➔ Garbage Collection
    ➔ Metrics etc..
    We can also changelog level without restarting of the application. This would help us in
    debugging any prod issue
    Sample UI : https://github.com/codecentric/spring-boot-admin

    View Slide

  22. Dashboard with Desktop Notifications

    View Slide

  23. View Application Health,
    Information & Details

    View Slide

  24. View Metric
    Counters

    View Slide

  25. Manage Logback
    logger levels

    View Slide

  26. Auditing
    Auditing would be achieved using AspectJ
    We can have the information like
    ➔ Who accessed the URL and from where
    ➔ How many requests have been successfully served to whom and how
    many got failed
    ➔ Which services - How many times - By Whom

    View Slide

  27. Performance Management
    Until now, We are using several tools to perform this task
    ● Jconsole
    ● JvisualVM
    ● Java Mission Control ( Comes with Java 8 )
    ● Logicmonitor (Paid)

    View Slide

  28. Performance Management
    Every time a new developer/user comes to the environment, we have to
    educate them to understand each of the tool.
    Spring Boot gives us a single tool ( Spring Admin Console) to do the
    performance management as well

    View Slide

  29. Transaction Management
    Spring gives us various ways to manage the transactions, In which two of them
    are very popular :
    ➔ Using Aspects
    ➔ Annotation Based

    View Slide
















  30. Using Aspect

    View Slide

  31. @Transactional
    public class DefaultFooService implements FooService {
    Foo getFoo(String fooName);
    Foo getFoo(String fooName, String barName);
    .
    .
    }

    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">



    Annotation

    View Slide

  32. Communication
    External :
    Using REST
    Internal :
    Using REST

    View Slide

  33. Testing
    - Unit testing
    - Junit
    - Integration Testing
    - Rest Client
    - Postman

    View Slide

  34. Demo

    View Slide

  35. ?

    View Slide

  36. Thank You!
    Follow us on
    www.walkingtree.tech

    View Slide