Skip to content

ignasf5/java_python_http_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Multithreading and Asynchronous API Calls with Kotlin Spring Boot

The documentation is incomplete.

Table of Contents

Introduction

In this project, we've developed a Kotlin Spring Boot application to test asynchronous API calls and demonstrate multithreading capabilities. The application interacts with a Flask API running locally to simulate HTTP requests.

For test part, we've developed a Python application with module of threading and another with concurrent.futures which sets settings at yaml format.

Conclusion

Key Features

  • Multithreading: Utilized Java 21 virtual threads to handle concurrent API requests efficiently.
  • Asynchronous API Calls: Demonstrated how to make asynchronous HTTP GET requests using Spring's RestTemplate.
  • Thread Identification: Included thread identifiers to differentiate threads calling the virtual threads API.
  • Performance Metrics: Recorded start and end times for API calls to calculate runtime.
  • Different xxx:
  • Test performance:

How to Use

  1. Ensure that both the Kotlin Spring Boot application and the Flask API are running locally.

Next Steps

  • Explore further optimization techniques for multithreading and asynchronous processing.
  • Experiment with different configurations and APIs to test performance under various conditions.
  • Consider integrating additional monitoring and logging tools for more detailed analysis.

Results

Action Kotlin thread pool Kotlin Multithreading Python thread pool Python concurrent
Calls x1000 x1000 x1000 x1000
Threads x10 - x10 x10
Time 1584 ms 462 ms 202555.592 ms 20467.969 ms

Documentation

Technologies Used

  • Kotlin 1.9.22
  • Spring Boot 3.2.3
  • Java 21 Virtual Threads
  • Python 3.9.0
  • requests==2.26.0
  • PyYAML==6.0
  • Flask==2.0.2

Setup Instructions

  1. Clone the repository to your local machine.
  2. Ensure you have JDK 17+ and Maven installed.
  3. Navigate to the project directory.
  4. Run mvn spring-boot:run to start the Kotlin Spring Boot application.
  5. Ensure the Flask API server is running locally on port 5000 http://localhost:5000/books/1, http://localhost:5000/books/2.
  6. Access http://localhost:8080/test-api, http://localhost:8080/test-api21 to trigger the asynchronous API requests.

Project Structure

  • src/main/kotlin/com/example/demo: Contains Kotlin source files.
    • Application.kt: Entry point for the Spring Boot application.
    • ApiController.kt: Controller class handling API requests.
  • src/main/resources: Contains application properties and configurations.
  • pom.xml: Maven project configuration file.

Additional Notes

  • This project serves as a demonstration of multithreading and asynchronous processing in Kotlin Spring Boot applications and python......
  • For any questions or issues, please open an issue on GitHub.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages