سؤال

I'm stuck with such issue. I have Client (just web page) and Server (some Java controller that handles requests from Client).

1) Client sends API request (POST or GET) to the Server and gets response in JSON format.

2) When the Server got request from Client, it saves API request in DB for statistic (user ID, timestamp, type of API request etc...). Also I need to save Bandwidth/ConnectionSpeed of this API request.

Question: Any ideas or suggestions how to solve this problem?

هل كانت مفيدة؟

المحلول

It will not be that easy from the Java Point of view. You might monitor times when you receive the request and when you return the answer to the user. You can also save the size of the JSON String and do your calculations, but that is only limited information as you will only be measuring the final throughput of your Server in terms of the JSON String. This is not only related to the servers network condition, but also to current server performance, and even client performance capabilities.

You might also try to sniff some packages with some OS-specific tool and compliment that to the database, but it would not be done with the API inside the app, you would have to find a trick to map this to your packages (meaning, each JSON String would need to have a unique ID, for example).

Another option is to look at your architecture, check what SW and HW components are involved, maybe some (reverse) proxy server or a load balancer can give you some of the information that's needed.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top