Friday, November 19, 2021

Moving Persistence layer to ES

If you are looking for faster reads and writes in the background Elastic search framework suits it best. You don't need to add any caching layer and the server side response time would  meet the SLA  ie. below the permissible response time.

What you need to do is:

1. Create an Index

II. and attach it to an alias. That's it and BOOM!!!

 Creating Index

{

  "settings": {

    "index": {

      "number_of_shards": "2",

      "number_of_replicas": "3"

    }

  },

  "mappings": {

    "tweets": {

      "dynamic": "false",

      "dynamic_templates": [

        {

          "no_index_template": {

            "match": "*",

            "mapping": {

              "index": "no",

              "include_in_all": false

            }

          }

        }

      ],

      "properties": {

        "documentId": {

          "type": "keyword",

          "index": false

        },

        "tweetId": {

          "type": "keyword",

          "index": true

        }...

      }

    }

  }

}

How to add aliases 

POST_aliases{

  "actions": [

    {

      "add": {

        "index": "user_tweets-<commit-id>",

        "alias": "user_tweets"

      }

    },

    {

      "remove": {

        "index": "user_tweets-<old_commit-id>",

        "alias": "user_tweets"

      }

    }

  ]

}


Designing Caching Layers to speed up Page Load Time

 

Go Through HAR report and identify the backend services consuming maximum time. Now  identify the bottlenecks and  explore how the response time can be minimised.

- Is there any caching happening in the backend Services?

-Is It possible to use some index based framework, elastic cache?

-Is Site front enabled for your various pages. If the content is too much and Site front is not copping up in the comparison has it been excluded for sitefront?

-Can the consumer cache the responses in some caching framework with certain TTL , For eg Memcache to store service endpoint as key and the response as value , ttl =1m.

Wednesday, November 17, 2021

Regex Cheat Sheet

1.  Matching a set of words :  Hello Brick, Brik data ,Brck -->. Bri?c?k.  


More:

^ 

Start                            

$

End                            


a?

one or more a                            


(?i)

case insensitive                        


a{3}

exactly 3 of  a                            


a{3,6}

between 3 and 6 of  a                            



(.*)(?i)(tech?i?e)(.*?) 

        tech, techi, techie, techie house, the techie house                          

\d    

Any digit, short for [0-9]

\D

A non-digit, short for [^0-9]

\s

A whitespace character, short for [ \t\n\x0b\r\f]

\S

A non-whitespace character, short for

\w

A word character, short for [a-zA-Z_0-9]

\W

A non-word character [^\w]

\S+

Several non-whitespace characters

\b   

Matches a word boundary where a word character is [a-zA-Z0-9_]                         


           

^\d{4}\sHELLO\s     

1234 HELLO some-other words

\S

A non-whitespace character, short for

\w

A word character, short for [a-zA-Z_0-9]

\W

A non-word character [^\w]

\S+

Several non-whitespace characters

\b   

Matches a word boundary where a word character is [a-zA-Z0-9_]                


Try out:  https://regex101.com/


Monday, November 8, 2021

HOW To design a Generic Architecture

 In Software it is very essential to craft a solution which caters to the all possible requirements. Thus it would be generic enough to be able to support new additions without any rewriting the framework.

Following are the methodologies developers can choose from based on the capabilities they are looking for:

  •  XML based configuration controlled.
  •  Annotation driven
  • Factory implementation
  • Abstract design
  • Java Reflection
  • Persisting Rules in DB 
  • Persisting Rules in Json format
  • Java Translation framework
  • Rule Engine
  • RabbitMQ Event driven soltion.