Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

long-running cURL, poll with sleep()?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    long-running cURL, poll with sleep()?

    I have a long-running cURL call (15-90 sec) that is running in an ajax callback on WAS instances, and I need to make the interaction as efficient/scalable as possible. It's my understanding that during the cURL call the entire WAS instance will be blocked and unable to respond to other requests.

    Alternatively, there's an Async HTTP API whereby I would make an initial cURL call that would kickoff the process and return a token, and then I would poll with the token until the process is complete. The benefit of this approach would be that each cURL interaction would be very quick.

    - How can I efficiently handle the polling?
    - I'm thinking a polling loop with calls to SLEEP()
    - During SLEEP() is the WAS instance available to handle other requests?

    Would I need to worry about this if running on IIS? (Iow, is this a WAS-only problem?)

    #2
    Re: long-running cURL, poll with sleep()?

    While executing a xbasic script (any xbasic script, cURL or otherwise) that WAS instance is busy and cannot fulfill any other requests. Using sleep() in your script will only make your wait longer. Like the documentation says, it pauses the script but you're still in it. I'm not familiar enough with IIS and Alpha but my understanding is the limitation is the same. It sounds like your alternative is the way to go.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant​​

    Comment


      #3
      Re: long-running cURL, poll with sleep()?

      Thanks for your insight into the sleep function. Sorry, but why do you think the Async HTTP alternative is the way to go? It seems that with either approach the WAS instance will be blocked until the remote work is complete and I might as well stick with the [simpler] long-running cURL call

      Comment


        #4
        Re: long-running cURL, poll with sleep()?

        You said, "The benefit of this approach would be that each cURL interaction would be very quick." ... maybe I misunderstood. It sounds like this alternative method would be a better option. If you can break up this script/method into smaller chunks (into multiple scripts) then that would free the WAS, in between these calls, to fulfill other requests. You shouldn't lock up the WAS for 90 seconds ...or even 15 seconds. Any other user who is on that instance will see this as an app problem, or click something multiple times, reload the page, etc.

        So, I guess the question is: Can you break up this method into smaller chunks? I too have long running processes. Some of which could take minutes or even up to an hour. I use Alpha's runtime for these really long processes. My user's can them be notified by email when it's complete or just return later to see it's status. To use Alpha runtime requires a separate license.
        Mike Brown - Contact Me
        Programmatic Technologies, LLC
        Programmatic-Technologies.com
        Independent Developer & Consultant​​

        Comment


          #5
          Re: long-running cURL, poll with sleep()?

          Truth is little different like in post #2 explained. Each client consumes threads and there is a limit how many threads WAS can handle. Alpha will create new one until the maximum amount of threads are in work. So WAS can handle many requests at same time. But to create a new thread is also basically a slow process. The client has to wait until one old thread is free or there is a new one available. Now WAS is totally slow. This behavior is easy to test. (How thread safe Alpha is in practice is an other question. From roadmap we get feeling that xbasic is not a thread safe).

          Situation is exactly same with Alpha IIS.

          This thread behavior is the main reason we now have Asp.Net Core.

          Ken

          Comment


            #6
            Re: long-running cURL, poll with sleep()?

            I see now how you were thinking. In my case, when user clicks a button they expect a response and are willing to wait, so unfortunately an asynchronous email notification or return visit is not an option.

            Turns out I had a conversation with someone at Alpha today that I think wraps up this question. Great news: the long-running cURL call does not block the WAS instance, so there's no need to worry about polling

            - the Xbasic engine is the shared resource to worry about, it's locked when a script starts running
            - before the script ends, however, the Xbasic lock can be released when certain functions are encountered. Specifically, database access, file I/O, cURL, sleep(), etc.
            - when the Xbasic lock is released other requests can be processed
            - when the database/cURL/sleep/etc operation completes, the thread gets back in line to have the Xbasic engine finish its script

            This all happens the same on WAS and IIS

            See 4th paragraph:
            https://www.alphasoftware.com/blog/i...ver-utlization

            Comment


              #7
              Re: long-running cURL, poll with sleep()?

              Nate, this is very useful information... thanks for sharing.

              Comment


                #8
                Re: long-running cURL, poll with sleep()?

                Originally posted by Davidk View Post
                Nate, this is very useful information... thanks for sharing.
                Yes, it is. I think I'll do some testing later for piece of mind. Sleep() will be an easy one. I've always been under the impression when a xbasic script is running no other requests are handled until the script is finished.
                Mike Brown - Contact Me
                Programmatic Technologies, LLC
                Programmatic-Technologies.com
                Independent Developer & Consultant​​

                Comment


                  #9
                  Re: long-running cURL, poll with sleep()?

                  Originally posted by mikeallenbrown View Post
                  I've always been under the impression when a xbasic script is running no other requests are handled until the script is finished.
                  Me too, and what caused me to start this thread. I specifically asked about sleep since we were discussing it earlier. Interested to hear what your testing shows

                  Comment


                    #10
                    Re: long-running cURL, poll with sleep()?

                    My simple test using sleep() seems to confirm what Alpha is saying. I've attached my component I made for testing this. In the component are notes.

                    Always a good idea for someone else to confirm the testing method is sound. I'm running 5667-5254 by the way.

                    sleep_Test.a5wcmp
                    Mike Brown - Contact Me
                    Programmatic Technologies, LLC
                    Programmatic-Technologies.com
                    Independent Developer & Consultant​​

                    Comment

                    Working...
                    X