Performance issues on Web Service

Discussion in 'ASP .Net Web Services' started by antijape@gmail.com, Mar 22, 2006.

  1. Guest

    I have a Web Service that returns very large string object. The string
    contais xmldata fetched directly from sql server by using xml explicit.
    The thing here is that if I get xml-document that is 11mb without web
    service it takes about 2 minutes. With web service it takes about 5min.
    This is acceptable. But when I get 37mb document without web service it
    takes about 5-6min but with web service it takes about 50min! As you
    can see this doesn't quite match up... The calls are excactly the same,
    so the problem isn't there. On the bigger document sqlserver does a
    little more work, but still (according to task manager) it's the web
    service that takes 80-90% of the time.

    The call is like this:
    Dim ws As New webservice
    ws.Timeout = System.Threading.Timeout.Infinite
    str = ws.getData
    Dim sw As StreamWriter = New StreamWriter("c:\Temp\data.xml",
    False)
    sw.Write(str)
    sw.Close()

    and the web service is like this:
    Dim conn As New SqlConnection(connstr)
    Dim sqlcom As New SqlCommand
    Dim sqlre As SqlDataReader

    sqlcom.CommandType = CommandType.StoredProcedure
    sqlcom.Connection = conn
    sqlcom.CommandTimeout = 1200
    sqlcom.CommandText = "getData"
    conn.Open()
    sqlre =
    sqlcom.ExecuteReader(CommandBehavior.CloseConnection)
    While sqlre.Read
    str = str & sqlre(0)
    End While
    --then close and return str

    I've also tried it like this:
    Private connec As ADODB.Connection
    Private comm As New ADODB.Command
    <XmlIgnore()> Private objStream As New ADODB.Stream
    <XmlIgnore()> Public str As String

    ------

    connec = Me.GetConnection()
    comm.CommandType = CommandType.StoredProcedure
    comm.CommandTimeout = 1200
    comm.ActiveConnection = connec
    comm.CommandText = "getData"
    objStream.Open()
    comm.Properties("Output Stream").Value = objStream
    objStream.Position = 0
    comm.Execute(, , 1024)
    str = objStream.ReadText
    --then close and return str

    but it's the same with this way too. Webmethod also has the
    "BufferResponse:=False" set. The return object could be xmldocument
    also, but if I've understood correctly returning string is better and
    then construct the xmldocument on client-side. The webservice is on
    localhost. Does anyone have any ideas why it's taking so long and maybe
    how it could be fixed?
    , Mar 22, 2006
    #1
    1. Advertising

  2. IIS is probably recycling because all the while you are holding the document
    in memory.

    Web services are really not the ideal tool for what you are trying to do -
    but then that is a design discussion.

    Regards,
    Pandurang
    --
    blog: www.thinkingMS.com/pandurang


    "" wrote:

    > I have a Web Service that returns very large string object. The string
    > contais xmldata fetched directly from sql server by using xml explicit.
    > The thing here is that if I get xml-document that is 11mb without web
    > service it takes about 2 minutes. With web service it takes about 5min.
    > This is acceptable. But when I get 37mb document without web service it
    > takes about 5-6min but with web service it takes about 50min! As you
    > can see this doesn't quite match up... The calls are excactly the same,
    > so the problem isn't there. On the bigger document sqlserver does a
    > little more work, but still (according to task manager) it's the web
    > service that takes 80-90% of the time.
    >
    > The call is like this:
    > Dim ws As New webservice
    > ws.Timeout = System.Threading.Timeout.Infinite
    > str = ws.getData
    > Dim sw As StreamWriter = New StreamWriter("c:\Temp\data.xml",
    > False)
    > sw.Write(str)
    > sw.Close()
    >
    > and the web service is like this:
    > Dim conn As New SqlConnection(connstr)
    > Dim sqlcom As New SqlCommand
    > Dim sqlre As SqlDataReader
    >
    > sqlcom.CommandType = CommandType.StoredProcedure
    > sqlcom.Connection = conn
    > sqlcom.CommandTimeout = 1200
    > sqlcom.CommandText = "getData"
    > conn.Open()
    > sqlre =
    > sqlcom.ExecuteReader(CommandBehavior.CloseConnection)
    > While sqlre.Read
    > str = str & sqlre(0)
    > End While
    > --then close and return str
    >
    > I've also tried it like this:
    > Private connec As ADODB.Connection
    > Private comm As New ADODB.Command
    > <XmlIgnore()> Private objStream As New ADODB.Stream
    > <XmlIgnore()> Public str As String
    >
    > ------
    >
    > connec = Me.GetConnection()
    > comm.CommandType = CommandType.StoredProcedure
    > comm.CommandTimeout = 1200
    > comm.ActiveConnection = connec
    > comm.CommandText = "getData"
    > objStream.Open()
    > comm.Properties("Output Stream").Value = objStream
    > objStream.Position = 0
    > comm.Execute(, , 1024)
    > str = objStream.ReadText
    > --then close and return str
    >
    > but it's the same with this way too. Webmethod also has the
    > "BufferResponse:=False" set. The return object could be xmldocument
    > also, but if I've understood correctly returning string is better and
    > then construct the xmldocument on client-side. The webservice is on
    > localhost. Does anyone have any ideas why it's taking so long and maybe
    > how it could be fixed?
    >
    >
    Pandurang Nayak, Mar 22, 2006
    #2
    1. Advertising

  3. Guest

    Thanks for the answer Pandurang. Isn't there really anything I can do
    about this? Maybe I could get the data in chunks, but since Biztalk and
    several other instances are included, it would be quite time consuming
    to build the solution... Any ideas?
    , Mar 23, 2006
    #3
  4. Why don't you look at FTP or something? There is good FTP support in Windows
    2003 and .NET 2.0.

    You could create a FTP site and this Web Service could "trigger" a FTP
    upload of the file. I think you could then use some FileWatcher
    component-based logic to raise required events when the file is transferred.

    Just an idea without really knowing your requirements.

    Regards,
    Pandurang
    --
    blog: www.thinkingMS.com/pandurang


    "" wrote:

    > Thanks for the answer Pandurang. Isn't there really anything I can do
    > about this? Maybe I could get the data in chunks, but since Biztalk and
    > several other instances are included, it would be quite time consuming
    > to build the solution... Any ideas?
    >
    >
    Pandurang Nayak, Mar 23, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jm
    Replies:
    1
    Views:
    500
    alien2_51
    Dec 12, 2003
  2. Ram
    Replies:
    6
    Views:
    7,614
    codezilla94
    Nov 13, 2007
  3. hocho888
    Replies:
    1
    Views:
    613
  4. Michael Averstegge
    Replies:
    0
    Views:
    4,204
    Michael Averstegge
    Jan 10, 2006
  5. Leo Violette
    Replies:
    0
    Views:
    1,005
    Leo Violette
    Apr 17, 2009
Loading...

Share This Page