Posts

How push notification works for FCM/Apple push (APNs) in network level

Question : How push notification works for FCM/Apple push (APNs) in network level? There are so many articles describes the push notification work flow in application level. But how APN servers sends the notifications to clients in network level are not explained in many articles. The answer is long polling connections from client devices(Mobiles, Laptops) to APN servers. why long polling connection? if its short connections then it leads to notification delays based on polling interval. APN servers are configured with long keepalive timeout(usually this timeout is very short around 60 secs to 300 secs in normal application servers) so push notifications will deliver to client devices immediately through same long lived TCP connection once APN receives the notification from app server side why polling comes here? TCP connection always disconnects if there is no internet or network change or device restarts, etc,… In this case, client device always keep trying/polling to the AP

Remove Large files in Git history

You pushed some large unnecessary files mistakenly in git, then just removing the file will not help we need to remove the file from git history. Steps to check the largest files: - cd my-repo - git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '/^blob/ {print substr($0,6)}' | sort --numeric-sort --key=2 --reverse | head | gcut --complement --characters=13-40 | gnumfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest Steps to remove the largest files: - Download the bfg.jar file(https://rtyley.github.io/bfg-repo-cleaner/). - git clone --mirror git@github.com:saravanan/my-repo.git - java -jar bfg.jar --delete-files large-file my-repo.git - cd my-repo.git - git reflog expire --expire=now --all && git gc --prune=now --aggressive - git push

docker.errors.APIError: 400 Client Error client is newer than server

You can face this issue when you are trying to use docker python library. Error: docker.errors.APIError: 400 Client Error: Bad Request for url: http+docker://localunixsocket/v1.26/images/json?only_ids=0&all=0 ("client is newer than server (client API version: 1.26, server API version: 1.24)") Solution: client= docker.from_env(version='auto') Use parameter "version" when instantiating a client.

Frequently update the AMI or Instance-Type in AWS Autoscaling group

If your instances running under AWS autoscaling, then instances will always use the same AMI or Instance-Type which configured in launch configuration. If you installed new packages or did any changes in instance root volume, then you need to take new AMI from that instance[root volume] and need to update that AMI in Autoscaling group[using launch configuration]. But it will require many manual steps. So I created a Bash script and it will do that task automatically. Example 1:- If you want to just update the AMI in Autoscaling group, run the script like below. #./script.sh <Autoscaling Group Name>  <Launch Configuration Name>  <AWS Region> Example 2:- If you want to  update both instance type and AMI in Autoscaling group, run the script like below. #./script.sh <Autoscaling Group Name>  <Launch Configuration Name>  <AWS Region>  <Instance Type> ==================================== #!/bin/bash AutoscalingGroupName=$1 LaunchCon

Very Good Tutorial To Learn Git

https://www.atlassian.com/git/ tutorials/what-is-version- control

Bash Script to find the exact application or command which consumed high CPU and Memory

#!/bin/bash #loadavg=$(awk '{ print $1 "\t" $2 "\t" $3 }' /proc/loadavg ) #To find the exact memory used percentage[Used-(Cached+Buffer)] Memusage=$(printf '%.0f\n' `free | awk 'FNR == 3{print $3/($3+$4)*100}'`) now=$(date +"%Y-%m-%d %H:%M:%S") #To find the cpu load average cpu_load=$(printf '%.0f\n' `uptime | awk '{print $(NF-2)}' | cut -c1-4`) if [ "$cpu_load" -ge "25" ] || [ "$Memusage" -ge "50" ];then   echo -e "\n\n=================\t$now\t========================" >> /var/log/top_report   top -b -c -n1 >> /var/log/top_report fi

Mongod is not stopping properly on Centos6.5

Just change the following line on function mongo_killproc() in mongod init script[line 94], # vim /etc/init.d/mongod local pid=`pidof ${procname}` instead of local pid=`pidofproc -p "${pid_file}" ${procname}`