{
  "attachments": [],
  "comments_archived": true,
  "date": "2002-04-15T18:54:03.000Z",
  "layout": "post",
  "title": "A personal server & Multi-threaded vs Async / Event-driven programming",
  "wordpress_id": 70,
  "wordpress_slug": "ooooio",
  "wordpress_url": "http://www.decafbad.com/blog/?p=70",
  "year": "2002",
  "month": "04",
  "day": "15",
  "isDir": false,
  "slug": "ooooio",
  "type": "entry",
  "postName": "2002-04-15-ooooio",
  "html": "<p>Okay after the <a href=\"http://radio.weblogs.com/0101679/2002/04/14.html#a351\">vote of confidence from Sam Ruby</a> about my thinking out loud about a <a href=\"http://www.decafbad.com/news_archives/000087.shtml#000087\">\"404 correction\" proxy server</a>, I've been thinking more about writing a Radio-like desktop app server.  I want to do more than make a <a href=\"http://www.decafbad.com/twiki/bin/view/Main/DesktopWebsite\">DesktopWebsite</a>, though.  I want to make a full-blown <a href=\"http://www.decafbad.com/twiki/bin/view/Main/PersonalServer\">PersonalServer</a> app, capable of hosting things like a <a href=\"http://www.decafbad.com/twiki/bin/view/Main/PersonalMailServer\">PersonalMailServer</a> and a slew of other little local web services &amp; etc.  I may end up giving up and working more within Radio, but <a href=\"http://www.decafbad.com/news_archives/000080.shtml#000080\">as I noted before</a> I have some issues with Radio's performance and stability, which though balanced by my appreciation of the elegance of the system, is being gradually outweighed by my fears of lock-in and pre-existing experience with other technologies.  </p>\n<p>Then again, this thing probably won't replace <a href=\"http://www.decafbad.com/twiki/bin/view/Main/RadioUserLand\">RadioUserLand</a> for me.  I use it daily, I bought it, and it's not as exciting to reimplement what I already have.  Unless it is exciting.  Make any sense?</p>\n<p>So, speaking of technologies... which ones should I use to start working on a personal server?  My main goals are mumbled <a href=\"http://www.decafbad.com/twiki/bin/view/Main/DesktopWebAppServer\">over here</a>.</p>\n<p>I've got a large amount of experience with Perl, and have written desktop apps with it for Mac OS X and Win32.  I'm having more fun with Python, however, and though I haven't written the same apps I imagine that it's on par with Perl.</p>\n<p>The main thing I'm trying to decide right now is:  multi-threaded vs async/event-driven.</p>\n<p>See, I need some sort of concurrency to handle multiple network server hits, multiple agents running, a scheduler, and whatever else wants to take up residence inside the <a href=\"http://www.decafbad.com/twiki/bin/view/Main/PersonalServer\">PersonalServer</a>.  <a href=\"http://www.decafbad.com/twiki/bin/view/Main/RadioUserLand\">RadioUserLand</a>, of course, has all of this.</p>\n<p>I've worked a lot with <a href=\"http://poe.perl.org/\">POE in Perl</a> to make some event-driven multitasking apps, a few servers (HTTP, FTP, NNTP, etc) and a few things to replace a fleet of forked scripts.  I've also started looking at <a href=\"http://www.twistedmatrix.com/documents/howto/ipc10paper\">Twisted in Python</a> which I gather to be the analogous thing in their camp.  Not the same, but they both are using the same basic idea of event-driven programs.</p>\n<p>The problem is that, to take code that you would have written for a forking or multi-threaded program, and make it play nice within the event-driven environment, there's a bit of re-think you need to do.  Loops need to be broken up into procedures, turned into self-running events, etc.</p>\n<p>Hmm... trying to think of more re-think examples, but the main one I can think of is that long-running loops and processes need to be sliced and diced.  I seem to remember more pain than that.</p>\n<p>Anyway, I'd rather use threads.  In threads, there needs to be a bit of re-think too, in terms of protecting resources from concurrency, but at least the main logic of my code can remain straightforward.  Perl doesn't have threads that I want to touch yet.  Python has threads, but I'm not sure how kosher they are.  Of course, there's always Java, but I want to avoid Java I think.</p>\n<p>Anyone tuned in out there with any thoughts?  Mostly thinking out loud right now.</p>\n\n\n<!--more-->\n\n\n<p>shortname=ooooio</p>\n<div id=\"comments\" class=\"comments archived-comments\"><h3>Archived Comments</h3>\n<ul class=\"comments\">\n<li class=\"comment\" id=\"comment-221082996\">\n<div class=\"meta\">\n<div class=\"author\">\n<a class=\"avatar image\" rel=\"nofollow\" href=\"\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=8c9c26bbf07df8085f59ae0f8982a3eb&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\" width=\"\" height=\"\"></a>\n<a class=\"avatar name\" rel=\"nofollow\" href=\"\">Ashutosh</a>\n</div>\n\n\n<p><a href=\"#comment-221082996\" class=\"permalink\"><time datetime=\"2002-04-18T04:54:35\">2002-04-18T04:54:35</time></a></p>\n</div>\n\n\n<div class=\"content\">I've been playing around with exactly the same idea - of a PersonalWebServer with built-in scheduler, object database etc. And again, Perl is my comfort zone. And the lack of decent thread support has been a stumbling block. I have too much work done in top level apps in Perl to change over to Python or anything else.\nAnyway, I used threads to invoke a scheduler thread and a http daemon thread as an experiment, and they seem to work pretty fine together.\nI plan to keep the Perl object database (presently embedded in my top level apps - using Storable persistant objects indexed using an RDBMS for searches using pre-configured object attributes) as an external server, and plan to get the PersonalWebAppServer to talk to the database server using XML-RPC.</div>\n\n\n</li>\n</ul>\n\n\n</div>\n\n\n",
  "body": "<p>Okay after the <a href=\"http://radio.weblogs.com/0101679/2002/04/14.html#a351\">vote of confidence from Sam Ruby</a> about my thinking out loud about a <a href=\"http://www.decafbad.com/news_archives/000087.shtml#000087\">\"404 correction\" proxy server</a>, I've been thinking more about writing a Radio-like desktop app server.  I want to do more than make a <a href=\"http://www.decafbad.com/twiki/bin/view/Main/DesktopWebsite\">DesktopWebsite</a>, though.  I want to make a full-blown <a href=\"http://www.decafbad.com/twiki/bin/view/Main/PersonalServer\">PersonalServer</a> app, capable of hosting things like a <a href=\"http://www.decafbad.com/twiki/bin/view/Main/PersonalMailServer\">PersonalMailServer</a> and a slew of other little local web services &amp; etc.  I may end up giving up and working more within Radio, but <a href=\"http://www.decafbad.com/news_archives/000080.shtml#000080\">as I noted before</a> I have some issues with Radio's performance and stability, which though balanced by my appreciation of the elegance of the system, is being gradually outweighed by my fears of lock-in and pre-existing experience with other technologies.  </p>\r\n<p>Then again, this thing probably won't replace <a href=\"http://www.decafbad.com/twiki/bin/view/Main/RadioUserLand\">RadioUserLand</a> for me.  I use it daily, I bought it, and it's not as exciting to reimplement what I already have.  Unless it is exciting.  Make any sense?</p>\r\n<p>So, speaking of technologies... which ones should I use to start working on a personal server?  My main goals are mumbled <a href=\"http://www.decafbad.com/twiki/bin/view/Main/DesktopWebAppServer\">over here</a>.</p>\r\n<p>I've got a large amount of experience with Perl, and have written desktop apps with it for Mac OS X and Win32.  I'm having more fun with Python, however, and though I haven't written the same apps I imagine that it's on par with Perl.</p>\r\n<p>The main thing I'm trying to decide right now is:  multi-threaded vs async/event-driven.</p>\r\n<p>See, I need some sort of concurrency to handle multiple network server hits, multiple agents running, a scheduler, and whatever else wants to take up residence inside the <a href=\"http://www.decafbad.com/twiki/bin/view/Main/PersonalServer\">PersonalServer</a>.  <a href=\"http://www.decafbad.com/twiki/bin/view/Main/RadioUserLand\">RadioUserLand</a>, of course, has all of this.</p>\r\n<p>I've worked a lot with <a href=\"http://poe.perl.org/\">POE in Perl</a> to make some event-driven multitasking apps, a few servers (HTTP, FTP, NNTP, etc) and a few things to replace a fleet of forked scripts.  I've also started looking at <a href=\"http://www.twistedmatrix.com/documents/howto/ipc10paper\">Twisted in Python</a> which I gather to be the analogous thing in their camp.  Not the same, but they both are using the same basic idea of event-driven programs.</p>\r\n<p>The problem is that, to take code that you would have written for a forking or multi-threaded program, and make it play nice within the event-driven environment, there's a bit of re-think you need to do.  Loops need to be broken up into procedures, turned into self-running events, etc.</p>\r\n<p>Hmm... trying to think of more re-think examples, but the main one I can think of is that long-running loops and processes need to be sliced and diced.  I seem to remember more pain than that.</p>\r\n<p>Anyway, I'd rather use threads.  In threads, there needs to be a bit of re-think too, in terms of protecting resources from concurrency, but at least the main logic of my code can remain straightforward.  Perl doesn't have threads that I want to touch yet.  Python has threads, but I'm not sure how kosher they are.  Of course, there's always Java, but I want to avoid Java I think.</p>\r\n<p>Anyone tuned in out there with any thoughts?  Mostly thinking out loud right now.</p>\r\n<!--more-->\r\nshortname=ooooio\r\n\r\n<div id=\"comments\" class=\"comments archived-comments\">\r\n            <h3>Archived Comments</h3>\r\n            \r\n        <ul class=\"comments\">\r\n            \r\n        <li class=\"comment\" id=\"comment-221082996\">\r\n            <div class=\"meta\">\r\n                <div class=\"author\">\r\n                    <a class=\"avatar image\" rel=\"nofollow\" \r\n                       href=\"\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=8c9c26bbf07df8085f59ae0f8982a3eb&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\"/></a>\r\n                    <a class=\"avatar name\" rel=\"nofollow\" \r\n                       href=\"\">Ashutosh</a>\r\n                </div>\r\n                <a href=\"#comment-221082996\" class=\"permalink\"><time datetime=\"2002-04-18T04:54:35\">2002-04-18T04:54:35</time></a>\r\n            </div>\r\n            <div class=\"content\">I've been playing around with exactly the same idea - of a PersonalWebServer with built-in scheduler, object database etc. And again, Perl is my comfort zone. And the lack of decent thread support has been a stumbling block. I have too much work done in top level apps in Perl to change over to Python or anything else.\r\n\r\nAnyway, I used threads to invoke a scheduler thread and a http daemon thread as an experiment, and they seem to work pretty fine together.\r\n\r\nI plan to keep the Perl object database (presently embedded in my top level apps - using Storable persistant objects indexed using an RDBMS for searches using pre-configured object attributes) as an external server, and plan to get the PersonalWebAppServer to talk to the database server using XML-RPC.</div>\r\n            \r\n        </li>\r\n    \r\n        </ul>\r\n    \r\n        </div>\r\n    ",
  "parentPath": "./content/posts/archives/2002",
  "path": "2002/04/15/ooooio",
  "summary": "Okay after the vote of confidence from Sam Ruby about my thinking out loud about a \"404 correction\" proxy server, I've been thinking more about writing a Radio-like desktop app server.  I want to do more than make a DesktopWebsite, though.  I want to make a full-blown PersonalServer app, capable of hosting things like a PersonalMailServer and a slew of other little local web services & etc.  I may end up giving up and working more within Radio, but as I noted before I have some issues with Radio's performance and stability, which though balanced by my appreciation of the elegance of the system, is being gradually outweighed by my fears of lock-in and pre-existing experience with other technologies.  \nThen again, this thing probably won't replace RadioUserLand for me.  I use it daily, I bought it, and it's not as exciting to reimplement what I already have.  Unless it is exciting.  Make any sense?\nSo, speaking of technologies... which ones should I use to start working on a personal server?  My main goals are mumbled over here.\nI've got a large amount of experience with Perl, and have written desktop apps with it for Mac OS X and Win32.  I'm having more fun with Python, however, and though I haven't written the same apps I imagine that it's on par with Perl.\nThe main thing I'm trying to decide right now is:  multi-threaded vs async/event-driven.\nSee, I need some sort of concurrency to handle multiple network server hits, multiple agents running, a scheduler, and whatever else wants to take up residence inside the PersonalServer.  RadioUserLand, of course, has all of this.\nI've worked a lot with POE in Perl to make some event-driven multitasking apps, a few servers (HTTP, FTP, NNTP, etc) and a few things to replace a fleet of forked scripts.  I've also started looking at Twisted in Python which I gather to be the analogous thing in their camp.  Not the same, but they both are using the same basic idea of event-driven programs.\nThe problem is that, to take code that you would have written for a forking or multi-threaded program, and make it play nice within the event-driven environment, there's a bit of re-think you need to do.  Loops need to be broken up into procedures, turned into self-running events, etc.\nHmm... trying to think of more re-think examples, but the main one I can think of is that long-running loops and processes need to be sliced and diced.  I seem to remember more pain than that.\nAnyway, I'd rather use threads.  In threads, there needs to be a bit of re-think too, in terms of protecting resources from concurrency, but at least the main logic of my code can remain straightforward.  Perl doesn't have threads that I want to touch yet.  Python has threads, but I'm not sure how kosher they are.  Of course, there's always Java, but I want to avoid Java I think.\nAnyone tuned in out there with any thoughts?  Mostly thinking out loud right now.",
  "needsBuild": true,
  "prevPostPath": "2002/04/15/oooohi",
  "prevPostTitle": "web bug / cgi-based access_log emulator?",
  "nextPostPath": "2002/04/15/ooooia",
  "nextPostTitle": "LiveJournal XML-RPC + metaWeblog API"
}