0

I have a Jetty web server running which accepts POST submissions from clients(currently just a java program that simulates what I want to be an Android device) The client program sends data via POST and the server process each request and stores them in a sql db.

Is this the correct way of communicating with the server? The client just periodically sends data to the server using POST. It does work but are there better ways to send data?

The client dont interact with any Form, the device just sends data to the server, this data could be anything.

6
  • 3
    What do you need to be "better?" Commented Nov 12, 2016 at 15:47
  • Im not sure if its the conventional way to send data.
    – brondy
    Commented Nov 12, 2016 at 15:49
  • What are the benefits that you are going to derive by being "conventional?" Commented Nov 12, 2016 at 15:49
  • okey lets say I simulate 1000 clients sending 100 request at the same time. Will the server load be better using other methods? I dont know other said methods though. Im wondering if im doing it correctly. It works but still asking
    – brondy
    Commented Nov 12, 2016 at 15:51
  • 1
    The server load will be affected by things that you have not mentioned in your question yet. The mechanism you use to transfer data is not especially meaningful in that context. In particular, the mechanism you're currently using seems perfectly adequate. Commented Nov 12, 2016 at 15:52

3 Answers 3

3

The purpose of your POST is to send data to the server. Is it fulfilling that function in a reasonably graceful way?

Nowadays, data is "conventionally" sent between machines on the internet using REST, an architectural style, and JSON, a data exchange format. But a few years ago we were using things like SOAP and XML. Tomorrow, we will be using QUBIT architecture, and REST will seem like old hat.

Do you need REST? Not unless you need the benefits it provides. REST is mostly about defining resources and having machines apply useful verbs to those resources. You can read about that here: http://www.looah.com/source/view/2284

1
  • Also, such conventions can be met "by accident", without being aware of that. Maybe you are doing REST already. The most important thing is to follow reasonable practises that solve the problem at hand. If these practises are common they might have a name, which helps communicating it to others.
    – null
    Commented Nov 12, 2016 at 22:32
1

There are many design considerations which might help you decide.

  • Does it need to be reliable? No? Then perhaps a binary UDP protocol is more suitable.
  • Does it require a minimal number of bits, because of power constraints? Perhaps MQTT is suitable.
  • Does it require an extreme amount of connections? Don't use TCP, but UDP.
  • Does it require very low latency? Then setting up connections might be a problem. Consider Websockets.

But, most of these requirements are probably not of your concern. Since you asked, I can safely assume you're in the 'easy' portion of the spectrum. A POST request will be sufficient.

0

Your question has merit, and it is probably due to the over used concept of simplicity. The word "simple" is now a meaningless grouping of letters or vocal sounds. The complexity of SW and it's attendant thought patterns have resulted in progression of hardware, but as far as SW is concerned, it is because of a (wait for it) simple question: "but, what if...". Because the act of composing code is physically easy and requires nothing (generally) but fingers, there seems to be an inbred determination to make software to everything all the time under any contingency. There is always that one guy who asks, "But what if..." and typing a few extra lines can supposedly satisfy the question. But then, think of a shovel. That's a pretty simple device. Cheap too. But imagine the explanation that tech writers would come up with towards the question: How do you use a shovel?

There would be paragraphs covering "left foot/right foot" digging. Hard dirt vs soft dirt digging. Digging vs just moving crap around. Digging while listening to music, which, of course, would be broken down into sub-categories of "rock n roll vs Opera" or "humming to oneself vs outright singing" must digging match the music at hand... and so on, presumably forever.

So, to answer your question, there is no right or wrong way to do software, there is only the way that works. Now, finding the way that works from the Internet? Well, may God help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.