skip to main content
10.1145/1250734.1250756acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
Article

Combining events and threads for scalable network services implementation and evaluation of monadic, application-level concurrency primitives

Published:10 June 2007Publication History

ABSTRACT

This paper proposes to combine two seemingly opposed programming models for building massively concurrent network services: the event-driven model and the multithreaded model. The result is a hybrid design that offers the best of both worlds--the ease of use and expressiveness of threads and the flexibility and performance of events.

This paper shows how the hybrid model can be implemented entirely at the application level using concurrency monads in Haskell, which provides type-safe abstractions for both events and threads. This approach simplifies the development of massively concurrent software in a way that scales to real-world network services. The Haskell implementation supports exceptions, symmetrical multiprocessing, software transactional memory, asynchronous I/O mechanisms and application-level network protocol stacks. Experimental results demonstrate that this monad-based approach has good performance: the threads are extremely lightweight (scaling to ten million threads), and the I/O performance compares favorably to that of Linux NPTL. tens of thousands of simultaneous, mostly-idle client connections. Such massively-concurrent programs are difficult to implement, especially when other requirements, such as high performance and strong security, must also be met.

References

  1. The ADAPTIVE Communication Environment: Object-Oriented Network Programming Components for Developing Client/Server Applications. 11th and 12th Sun Users Group Conference, December 1993 and June 1994.Google ScholarGoogle Scholar
  2. Atul Adya, Jon Howell, Marvin Theimer, William J. Bolosky, and John R. Douceur. Cooperative Task Management without Manual Stack Management. In Proceedings of the 2002 Usenix Annual Technical Conference, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Andrew Appel. Compiling with Continuations. Cambridge University Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Joe Armstrong, Robert Virding, Claes Wikström, and Mike Williams. Concurrent Programming in Erlang, Second Edition. Prentice-Hall, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Gerard Berry and Georges Gonthier. The Esterel Synchronous Programming Language: Design, Semantics, Implementation. Science of Computer Programming, 19(2):87--152, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Steve Bishop, Matthew Fairbairn, Michael Norrish, Peter Sewell, Michael Smith, and Keith Wansbrough. Rigorous specification and conformance testing techniques for network protocols, as applied to TCP, UDP, and sockets. In SIGCOMM '05: Proceedings of the 2005 conference on Applications, technologies, architectures, and protocols for computer communications, pages 265--276, New York, NY, USA, 2005. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Brendan Burns, Kevin Grimaldi, Alexander Kostadinov, Emery D. Berger, and Mark D. Corner. Flux: A language for programming high-performance servers. In 2006 USENIX Annual Technical Conference, pages 129--142, June 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Koen Claessen. A Poor Man's Concurrency Monad. Journal of Functional Programming, 9(3):313--323, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Kathleen Fisher and John Reppy. Compiler Support for Lightweight Concurrency. Technical memorandum, Bell Labs, March 2002.Google ScholarGoogle Scholar
  10. Emden R. Gansner and John H. Reppy. A Multi-threaded Higher-order User Interface Toolkit. In User Interface Software, Bass and Dewan (Eds.), volume 1 of Software Trends, pages 61--80. John Wiley & Sons, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. The Glasgow Haskell Compiler. http://www.haskell.org/ghc.Google ScholarGoogle Scholar
  12. Tim Harris, Maurice Herlihy, Simon Marlow, and Simon Peyton-Jones. Composable Memory Transactions. In Proceedings of the ACM Symposium on Principles and Practice of Parallel Programming, June 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Galen C. Hunt, James R. Larus, Martin Abadi, Mark Aiken, Paul Barham, Manuel Fahndrich, Chris Hawblitzel, Orion Hodson, Steven Levi, Nick Murphy, Bjarne Steensgaard, David Tarditi, Ted Wobber, and Brian Zill. An Overview of the Singularity Project. Technical Report MSR-TR-2005-135, Microsoft Research, Redmond, WA, USA, October 2005.Google ScholarGoogle Scholar
  14. Simon Peyton Jones, Andrew Gordon, and Sigbjorn Finne. Concurrent Haskell. In POPL '96: The 23 rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 295--308, St. Petersburg Beach, Florida, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. James R. Larus and Michael Parkes. Using Cohort-Scheduling to Enhance Server Performance. In USENIX Annual Technical Conference, General Track, pages 103--114, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Hugh C. Lauer and Roger M. Needham. On the Duality of Operating Systems Structures. In Proceedings Second International Symposium on Operating Systems. IRIA, October 1978.Google ScholarGoogle Scholar
  17. Simon Marlow. Developing a High-performance Web Server in Concurrent Haskell. Journal of Functional Programming, 12, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Eugenio Moggi. Computational lambda-calculus and monads. In Proceedings of the Fourth Annual IEEE Symposium on Logic in Computer Science, pages 14- 23, Pacific Grove, California, June 1989. IEEE. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. John K. Outsterhout. Why Threads Are A Bad Idea (for most purposes). In Presentation given at the 1996 Usenix Annual Technical Conference, 1996.Google ScholarGoogle Scholar
  20. Vivek S. Pai, Peter Druschel, and Willy Zwaenepoel. Flash: An efficient and portable Web server. In Proceedings of the USENIX 1999 Annual Technical Conference, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Rob Pike. A Concurrent Window System. Computing Systems, 2(2):133--153, Spring 1989.Google ScholarGoogle Scholar
  22. John H. Reppy. CML: A Higher Concurrent Language. In PLDI'91: Proceedings of the ACM SIGPLAN 1991 Conference on Programming Language Design and Implementation, pages 293--305, New York, NY, USA, 1991. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Olin Shivers. Continuations and Threads: Expressing Machine Concurrency Directly in Advanced Languages. In Proceedings of the Second ACM SIGPLAN Workshop on Continuations, 1997.Google ScholarGoogle Scholar
  24. The Twisted Project. http://twistedmatrix.com/.Google ScholarGoogle Scholar
  25. Rob von Behren, Jeremy Condit, and Eric Brewer. Why Events Are A Bad Idea (for high-concurrency servers). In Proceedings of the 10th Workshop on Hot Topics in Operating Systems (HotOS IX), May 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Rob von Behren, Jeremy Condit, Feng Zhou, George C. Necula, and Eric Brewer. Capriccio: Scalable threads for internet services. In Proceedings of the Ninteenth Symposium on Operating System Principles (SOSP), October 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Philip Wadler. Monads for Functional Programming. In Proceedings of the Marktoberdorf Summer School on Program Design Calculi, August 1992.Google ScholarGoogle Scholar
  28. Matt Welsh, David E. Culler, and Eric A. Brewer. SEDA: An Architecture for Well-Conditioned, Scalable Internet Services. In Proceedings of the Symposium on Operating System Principles (SOSP), 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Nickolai Zeldovich, Alexander Yip, Frank Dabek, Robert Morris, David Mazières, and Frans Kaashoek. Multiprocessor support for event-driven programs. In Proceedings of the 2003 USENIX Annual Technical Conference (USENIX '03), San Antonio, Texas, June 2003.Google ScholarGoogle Scholar

Index Terms

  1. Combining events and threads for scalable network services implementation and evaluation of monadic, application-level concurrency primitives

                  Recommendations

                  Comments

                  Login options

                  Check if you have access through your login credentials or your institution to get full access on this article.

                  Sign in
                  • Published in

                    cover image ACM Conferences
                    PLDI '07: Proceedings of the 28th ACM SIGPLAN Conference on Programming Language Design and Implementation
                    June 2007
                    508 pages
                    ISBN:9781595936332
                    DOI:10.1145/1250734
                    • cover image ACM SIGPLAN Notices
                      ACM SIGPLAN Notices  Volume 42, Issue 6
                      Proceedings of the 2007 PLDI conference
                      June 2007
                      491 pages
                      ISSN:0362-1340
                      EISSN:1558-1160
                      DOI:10.1145/1273442
                      Issue’s Table of Contents

                    Copyright © 2007 ACM

                    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

                    Publisher

                    Association for Computing Machinery

                    New York, NY, United States

                    Publication History

                    • Published: 10 June 2007

                    Permissions

                    Request permissions about this article.

                    Request Permissions

                    Check for updates

                    Qualifiers

                    • Article

                    Acceptance Rates

                    Overall Acceptance Rate406of2,067submissions,20%

                    Upcoming Conference

                    PLDI '24

                  PDF Format

                  View or Download as a PDF file.

                  PDF

                  eReader

                  View online with eReader.

                  eReader