Find the answer to your Linux question:
Page 3 of 3 FirstFirst 1 2 3
Results 21 to 27 of 27
It sounds like you want to add interactivity to web pages, so good starting topics to search would be ajax, jquery and ajax, ajax and php, ajax vs web sockets. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #21
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,488

    It sounds like you want to add interactivity to web pages, so good starting topics to search would be ajax, jquery and ajax, ajax and php, ajax vs web sockets. Ajax can be pretty reliable if you handle your errors properly at both ends.

    FastCGI is reportedly much more scalable than mod-php but I haven't had an opportunity to compare them in a suitably loaded environment. If I was getting to the point I cared and didn't need all the additional features that Apache provides, I'd be considering lighter and more focussed web servers such as nginx and Cherokee instead.
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    Conkybots: Interactive plugins for your Conkys!

  2. #22
    Linux User IsaacKuo's Avatar
    Join Date
    Feb 2005
    Location
    Baton Rouge, LA, USA
    Posts
    405
    Quote Originally Posted by gregm View Post
    Apache isn't really designed for WebSockets for anything other then a very limited use. If you are going to use WebSockets you should install a server optimized for that purpose. It's also worth taking into account that WebSockets in older browsers are likely not implemented so something along the lines of long polling is done to approximate the effect.

    IMO the advantage of WebSockets is primarily that real time (or pseudo real time) server side notifications are possible with them but if everything is being initiated from the client side they are the wrong model and there is no efficiency gain over persistent HTTP (and a sensible architecture) and a greatly increased cost server side.
    A chat application involves real time server side notifications, especially for the one described here (which would have updates for each key press by anyone else in the chat room).

    Long polling and similar hacks can give you acceptable performance, but they are complex to code. They are hard to even understand in the first place if you're not already familiar with traditional AJAX and its shortcomings. Resetreset is new at this, so something easier to code and understand is called for.
    Isaac Kuo, ICQ 29055726 or Yahoo mechdan

  3. #23
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    903
    Quote Originally Posted by elija View Post

    FastCGI is reportedly much more scalable than mod-php but I haven't had an opportunity to compare them in a suitably loaded environment. If I was getting to the point I cared and didn't need all the additional features that Apache provides, I'd be considering lighter and more focussed web servers such as nginx and Cherokee instead.
    We were using Nginx with FastCGI for a huge Drupal site and it was excellent. The only thing was learn how to tune the Nginx was tricky. I hear latest versions of Nginx are getting easier to tune the config.
    A lion does not lose sleep, over the opinion of sheep.

  4. #24
    Linux User
    Join Date
    Mar 2013
    Posts
    268
    OK, OK, what I wanted was drop down suggestions for a input box, like Google. Isaac, thanks for looking out for me

    As it happens, I *had* a book which gave me the vital data that I need, I had just forgotten about it temporarily. And greg of course, answered my question right back there, about char **environ , so... thanks all of you

    What exactly is "long polling"?

  5. #25
    Linux User IsaacKuo's Avatar
    Join Date
    Feb 2005
    Location
    Baton Rouge, LA, USA
    Posts
    405
    Quote Originally Posted by resetreset View Post
    OK, OK, what I wanted was drop down suggestions for a input box, like Google. Isaac, thanks for looking out for me

    What exactly is "long polling"?
    Ah, this task is much simpler than a chat application, and it does not require anything like long polling. Long polling is a hack on the way HTTP requests work, that lets the client receive data at any arbitrary time. This is useful for a chat application because you don't know beforehand when the server will need to send you new chats from other users.

    The way HTTP requests normally work is that the client sends a request to the server and the server returns data as quickly as it can. So, the web browser sends a request for INDEX.HTML and the web server returns the contents of INDEX.HTML as soon as it can. This works perfectly fine for your task. The client sends the input box data, the server returns with a list of suggestions as quickly as it can.

    It's not so good for a chat application, because the client could just be sitting there with no data to send, but someone else sends a message. The server now needs to get this new data to you, but it can't initiate contact. The traditional AJAX solution is for the client to repeatedly send HTTP requests every second or so just in case there is new data to receive. How often does the client poll the server for data? It's a trade-off. Too often, and the server is overwhelmed with requests. Too infrequently, and the client could be waiting a long time before the new text shows up.

    Long polling is a hack to solve this problem. The client still sends an HTTP request for data, but the server does not immediately return anything. Instead, it leaves the connection open for some seconds if there's nothing immediately available to send. If someone else sends a chat, then the server can now immediately broadcast that chat text to the client waiting for data. This isn't really how HTTP was originally meant to be used, and it may have some performance issues of its own depending on the specifics of the web server. But mainly, it's more complex for the developer to understand and troubleshoot. Which is fine, for someone experienced. It's not the best way to get started.

    Now like I said, for your application this is not an issue. You don't need to use long polling, because you only care about sending data to the client when it explicitly requests data (and you want to send this data ASAP).
    Isaac Kuo, ICQ 29055726 or Yahoo mechdan

  6. #26
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,488
    Check out the jquery ui library. It has a widget that will do what you want. No sense re-inventing the wheel unless you are learning to make wheels!
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    Conkybots: Interactive plugins for your Conkys!

  7. #27
    Linux User
    Join Date
    Mar 2013
    Posts
    268
    Thanks guys, specially Isaac for that long and detailed explanation

Page 3 of 3 FirstFirst 1 2 3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •