Showing posts with label Springboot. Show all posts
Showing posts with label Springboot. Show all posts

Monday, November 15, 2021

The fundamental principles for using microservices for modernization

The last few years I have spent a lot of time building new application on microservices and also moving parts of monolith to microservices. I I have researched and tried sharing my practical experience in several articles on this topic.

This week my second blog on some foundational principles of microservices published on Capgemini website.

https://www.capgemini.com/se-en/2021/11/the-fundamental-principles-for-using-microservices-for-modernization/

Sunday, November 29, 2020

Extracting running data out of NRC/Nike + (Nike Run Club) using API's

For the past few weeks, I have been struggling to see the running kilometers getting updated in my  Nike + App. It could be a bug or a weird feature of the app and since this was kind of a demotivation, I decided to go ahead and create my own dashboard to calculate the results. Also, for some reason, Nike discontinued viewing and editing activities on the web.

Considering I had about 8 years of data and you never know when this kind of apps stop to exist or when they become paid versions. It's always better to persist your data to a known source and if required use it to feed it into any other application. I also went ahead and uploaded my data to UnderArmour's "MapMyFitness" App which has much better open-source documentation. 

It turns out that there is a lot of additional information the NRC app captures which are typically not shown on the mobile app. Few of the information include 

  1. Total Steps during the workout including detail split between intervals
  2. Weather Details during the workout 
  3. Amount of the time the workout was halted for 
  4. Location details including latitude and longitude information that can help you plot your own Map

Coming to the API part, I could not get hold of any official Nike documentation, but came across some older blogs https://gist.github.com/niw/858c1ecaef89858893681e46db63db66 in which they mentioned few API endpoints to fetch the historic activities. I ended up creating a  spring-boot version of fetching the activities and storing it in a CSV format in my Google Drive. 

The code can be downloaded here ->  https://github.com/shailendrabhatt/Nike-run-stats

The code also includes a postman repository which contains a Collection that can also be used to fetch one's activities. Just update the {{access_token}} and run the Get requests.

While the blog that had details of the API was good enough, a few tips that can be helpful 

  • Fetching the Authorization token can be tricky and it has an expiry time. For that, you will need a https://www.nike.com/se/en/nrc-app account and fetch the authorization token from the XML HTTP request headers for the URL type api.nike.com. There are few requests hitting this URL and the token can be fetched from any of them.
  • The API described in the link shows details of after_time, one can also fetch before_time information 
/sport/v3/me/activities/after_time/${time}
/sport/v3/me/activities/before_time/${time} 
  • Pagination can be easily achieved using the before_id and after_id. These ids are of different formats ranging from GUIDs to a single-digit number and can be confusing.

Thursday, December 5, 2019

How to develop a quick load test for your micro service application

Ensuring the performance and scalability of the applications is crucial. Load testing is a key practice to identify bottlenecks and optimize your Spring Boot microservices. This article explains the process of developing a quick load test on Spring Boot microservice using Apache JMeter.

Load Test Setup:

Follow the below steps to set up a quick load test:

Step 1: Install JMeter Plugins (Optional)
If you haven't installed the JMeter Plugins Manager, do so by following the instructions on the official website: https://jmeter-plugins.org/wiki/PluginsManager/

Once installed, open JMeter, go to "Options," and select "Plugins Manager" to install the necessary plugins for your load test.

Step 2: Create a New JMeter Test Plan
Open JMeter and create a new Test Plan:

Right-click on the Test Plan node.
Choose "Add" > "Threads (Users)" > "Thread Group."
Set the number of threads (virtual users) and loop count according to your testing requirements.

Step 3: Add HTTP Request
Right-click on the Thread Group.
Choose "Add" > "Sampler" > "HTTP Request."
Configure the HTTP Request sampler with your microservice's endpoint details.

Step 4: Add Listeners for Monitoring
To analyze the test results, add listeners:

Right-click on the Thread Group.
Choose "Add" > "Listener."
Add listeners such as "View Results Tree," "Summary Report," and "Response Times Over Time."

Step 5: Configure Timers (Optional)
To simulate realistic user behavior, add timers:

Right-click on the Thread Group.
Choose "Add" > "Timer."
Configure timers like "Constant Timer" or "Gaussian Random Timer" to introduce delays between requests.

Step 6: Run the Load Test
Save your test plan and run the load test:

Click on the "Run" menu and choose "Start" or use the green "Play" button.
Monitor the results in real-time using the listeners you added. Pay attention to response times, throughput, and error rates.

Step 7: Analyze and Optimize
After the test completes, analyze the results to identify performance bottlenecks. Optimize your microservice accordingly and iterate the load testing process.

Conclusion:

Load testing with JMeter is a powerful way to ensure the performance and scalability of any Spring Boot microservices. By following these steps, you can quickly set up a load test, identify potential issues, and fine-tune your microservices for optimal performance in a production environment. Remember to regularly conduct load tests to catch performance issues early in the development lifecycle.

Building Microservices by decreasing Entropy and increasing Negentropy - Series Part 5

Microservice’s journey is all about gradually overhaul, every time you make a change you need to keep the system in a better state or the ...