Re: structs for data transfer?

From: nospam (nospam_at_example.com)
Date: 09/22/04


Date: Wed, 22 Sep 2004 07:50:32 -0400

away wrote:

> Why XML/HTTP is slow?

on a standard x86 compiler
        short n=htons(h);
will translate into 2 CPU instruction if optimisation is on

ostringstream str;
str<<"<val>"<<h<<"</val>";
string n=str.str();

will be at least hundreds if no more. It will require heap alocation etc...

in first example sizeof(s) will be 2
into the second s.size() will be at least 12 and at most 16.
If you add the <?xml version="1.0" ..... or namespaces
you got the point.

A dedicated TCP protocol implemented can send messages using only
a minimum overhead (like you can define your own message header with
one byte message type and a long the message size). Just compare the size
of a minimal http header with that. The http being stateless, you may need
to implement your own state keeping procedure if you need that. The
amount of the code executed inside of a application server prior to the
message reaching your handlers can be estimated very conservative to at
least thousands CPU instructions.

For most applications this is OK. If your request is going to make a query
into a database with milions of records, the overhead not significant
compared with the time spent in query. However, for some aplications
it may be unacceptable.

The point I made was NOT that you do not have to use XML. XML is very good
for most of the applications. But you can not state that this is the only
solution, as your answer:
"""
You need to serialize your data into XML, and then transfer that in a higher
level protocol, such as HTTP.
"""
 
without having a good insight of OP problem.

And by the way, there are over there some modern C++ socket libraries
and with a good implementation of message serialization, a custom socket
protocol may be way easier to implement that J2EE server side solution :-)

> What consists overheads of SOAP?

Usually, SOAP just double the amount of data to be send
(serialized/send/deserialized) over a simple POST over HTTP.
Just look at the SOAP envelope required to send a single integer
as specified above :-)

Again, if your application do a query at every 2 seconds over a SQL
database, it do not mater. But at 100+ msg/s a SOAP implementation
will just collapse.

> Thanks for your insights in advance!

You are welcome.



Relevant Pages

  • Re: Classic ASP to .NET WebService interfacing (Dataset to RecordSet)
    ... > really just looking to utilize SOAP as an alternative. ... then loads the resultant xml into a MSXML2.DomDocument ... HTTP, XML ... Please reply to the newsgroup. ...
    (microsoft.public.inetserver.asp.general)
  • Re: googling google persistance using google api
    ... know that the demo uses SOAP and I know that I know nothing about SOAP ... I'm not an expert on SOAP, but my understanding is that it's just passing XML documents around as messages, primarily using the HTTP protocol. ...
    (comp.lang.java.help)
  • Re: structs for data transfer?
    ... many people use XML over HTTP or even SOAP for the job ... About SOAP, my advice is use it only when is mandatory: ... struct of OP will waste about 20..50 times ...
    (comp.lang.cpp)
  • Re: Classic ASP to .NET WebService interfacing (Dataset to RecordSet)
    ... really just looking to utilize SOAP as an alternative. ... >>classic ASP server. ... it makes an HTTP GET ... > the resultant xml into a MSXML2.DomDocument and transforms the xml to html ...
    (microsoft.public.inetserver.asp.general)
  • mail merge http-sourced data
    ... to serve-up a Word mail-merge document (as XML) over HTTP, ... linked to data that is also served over HTTP. ... This actually does work, except that it prompts annoyingly, 2 to 3 times. ...
    (microsoft.public.word.mailmerge.fields)