skip to main content
research-article
Open Access

There is no fork: an abstraction for efficient, concurrent, and concise data access

Published:19 August 2014Publication History
Skip Abstract Section

Abstract

We describe a new programming idiom for concurrency, based on Applicative Functors, where concurrency is implicit in the Applicative <*> operator. The result is that concurrent programs can be written in a natural applicative style, and they retain a high degree of clarity and modularity while executing with maximal concurrency. This idiom is particularly useful for programming against external data sources, where the application code is written without the use of explicit concurrency constructs, while the implementation is able to batch together multiple requests for data from the same source, and fetch data from multiple sources concurrently. Our abstraction uses a cache to ensure that multiple requests for the same data return the same result, which frees the programmer from having to arrange to fetch data only once, which in turn leads to greater modularity.

While it is generally applicable, our technique was designed with a particular application in mind: an internal service at Facebook that identifies particular types of content and takes actions based on it. Our application has a large body of business logic that fetches data from several different external sources. The framework described in this paper enables the business logic to execute efficiently by automatically fetching data concurrently; we present some preliminary results.

References

  1. S. Awodey. Category Theory, volume 49 of Oxford Logic Guides. Oxford University Press, 2006.Google ScholarGoogle ScholarCross RefCross Ref
  2. K. Claessen. A poor man's concurrency monad. J. Funct. Program., 9 (3): 313--323, May 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. M. Eriksen. Your server as a function. In Proceedings of the Seventh Workshop on Programming Languages and Operating Systems, PLOS '13, pages 5:1--5:7. ACM, 2013. ISBN 978-1-4503-2460-1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. W. L. Harrison. Cheap (but functional) threads. Submitted for publication, http://people.cs.missouri.edu/~harrisonwl/drafts/CheapThreads.pdf.Google ScholarGoogle Scholar
  5. P. Li and S. Zdancewic. Combining events and threads for scalable network services implementation and evaluation of monadic, application-level concurrency primitives. In Proceedings of the 2007 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI '07, pages 189--199, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. S. Marlow. An extensible dynamically-typed hierarchy of exceptions. In Proceedings of the 2006 ACM SIGPLAN Workshop on Haskell, Haskell '06, pages 96--106, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. C. Mcbride and R. Paterson. Applicative programming with effects. J. Funct. Program., 18 (1): 1--13, Jan. 2008. ISSN 0956-7968. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. E. Meijer. Reactive extensions (Rx): Curing your asynchronous programming blues. In ACM SIGPLAN Commercial Users of Functional Programming, CUFP '10, pages 11:1--11:1. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. S. Peyton Jones, D. Vytiniotis, S. Weirich, and G. Washburn. Simple unification-based type inference for GADTs. In Proceedings of the Eleventh ACM SIGPLAN International Conference on Functional Programming, ICFP '06, pages 50--61. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. E. Scholz. A concurrency monad based on constructor primitives, or, being first-class is not enough. Technical report, Universität Berlin, 1995.Google ScholarGoogle Scholar
  11. T. Stein, E. Chen, and K. Mangla. Facebook immune system. In Proceedings of the 4th Workshop on Social Network Systems, SNS '11, pages 8:1--8:8. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. W. Swierstra and T. Altenkirch. Beauty in the beast. In Proceedings of the ACM SIGPLAN Workshop on Haskell Workshop, Haskell '07, pages 25--36, 2007. ISBN 978-1-59593-674-5. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. D. Syme, T. Petricek, and D. Lomov. The F# asynchronous programming model. In Practical Aspects of Declarative Languages, volume 6539 of Lecture Notes in Computer Science, pages 175--189. Springer Berlin Heidelberg, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. V. Venkataramani, Z. Amsden, N. Bronson, G. Cabrera III, P. Chakka, P. Dimov, H. Ding, J. Ferris, A. Giardullo, J. Hoon, S. Kulkarni, N. Lawrence, M. Marchukov, D. Petrov, and L. Puzar. TAO: How facebook serves the social graph. In Proceedings of the 2012 ACM SIGMOD International Conference on Management of Data, SIGMOD '12, pages 791--792, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Vouillon. Lwt: A cooperative thread library. In Proceedings of the 2008 ACM SIGPLAN Workshop on ML, ML '08, pages 3--12. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. There is no fork: an abstraction for efficient, concurrent, and concise data access

      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

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!