You are previewing ASP.NET Core 1.0 High Performance.
O'Reilly logo
ASP.NET Core 1.0 High Performance

Book Description

Create fast, scalable, and high performance applications with C#, ASP.NET Core 1.0, and MVC 6

About This Book

  • Learn the importance of measuring, profiling, and locating the most impactful problems

  • Discover the common areas you might encounter performance problems and areas you don’t need to worry about

  • Understand the differences between development workstations and production infrastructure and how these can amplify problems

  • Design workflows that run asynchronously and are resilient to transient performance issues

  • Who This Book Is For

    This book is for ASP.NET and C# developers who have experience with the MVC framework for web application development and are looking to deploy applications that will perform well in live production environments. These could be virtual machines or hosted by a cloud service provider such as AWS or Azure.

    What You Will Learn

  • Why performance matters and when it should be considered

  • Use different tools to measure performance

  • Spot common performance issues, their root causes, and how to easily mitigate them

  • Improve performance at the network level and I/O level, and how to optimize the application as a whole

  • Work with caching and message queuing tools, including patterns and strategies

  • Discover the dark side of performance improvement and find out how to manage complexity

  • Monitor performance as part of continuous integration and regression testing

  • Assess and solve performance issues with other advanced technologies

  • In Detail

    ASP.NET Core is the new, open source, and cross-platform, web-application framework from Microsoft. It's a stripped down version of ASP.NET that's lightweight and fast. This book will show you how to make your web apps deliver high performance when using it.

    We'll address many performance improvement techniques from both a general web standpoint and from a C#, ASP.NET Core, and .NET Core perspective. This includes delving into the latest frameworks and demonstrating software design patterns that improve performance.

    We will highlight common performance pitfalls, which can often occur unnoticed on developer workstations, along with strategies to detect and resolve these issues early. By understanding and addressing challenges upfront, you can avoid nasty surprises when it comes to deployment time.

    We will introduce performance improvements along with the trade-offs that they entail. We will strike a balance between premature optimization and inefficient code by taking a scientific- and evidence-based approach. We'll remain pragmatic by focusing on the big problems.

    By reading this book, you'll learn what problems can occur when web applications are deployed at scale and know how to avoid or mitigate these issues. You'll gain experience of how to write high-performance applications without having to learn about issues the hard way.

    You'll see what's new in ASP.NET Core, why it's been rebuilt from the ground up, and what this means for performance. You will understand how you can now develop on and deploy to Windows, Mac OS X, and Linux using cross-platform tools, such as Visual Studio Code.

    Style and approach

    Starting with a drill down into the nuts and bolts of various performance parameters, you will get an understanding of the ASP.NET MVC 6 framework with the help of rich code-based examples that will equip you to build highly scalable and optimized applications.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. ASP.NET Core 1.0 High Performance
      1. ASP.NET Core 1.0 High Performance
      2. Credits
      3. Foreword
      4. About the Author
      5. Acknowledgments
      6. About the Reviewer
        1. eBooks, discount offers, and more
          1. Why subscribe?
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Why Performance Is a Feature
        1. Performance as a feature
        2. Common classes of performance problems
          1. Language considerations
          2. Types of performance problems
            1. When performance matters
              1. Slower is sometimes better
            2. Why issues are missed
              1. Measuring
          3. The benefits of planning ahead
        3. Understanding hardware
          1. Storage access speeds
          2. Scaling approach changes
        4. Tools and costs
          1. Tools
          2. Looking at some alternative tools
        5. The new .NET
        6. Summary
      10. 2. Measuring Performance Bottlenecks
        1. Tools
          1. SQL
            1. SQL Server Profiler
              1. Executing a simple query
            2. MiniProfiler
          2. Application profiling
            1. Glimpse
              1. Using Glimpse
            2. IDE
          3. Monitoring HTTP
            1. Browsers
              1. Chrome
              2. Firefox
            2. Fiddler
          4. Network
            1. Microsoft Message Analyzer
            2. Wireshark
          5. Roll your own
        2. Science
          1. Repeatability
            1. Only change one thing
        3. Summary
      11. 3. Fixing Common Performance Problems
        1. Latency
        2. Asynchronous operations
          1. Simple asynchronous tools
          2. Background queuing
          3. Hangfire
        3. Select N+1 problems
          1. Efficient paging
          2. Static site generators
        4. Pragmatic solutions with hardware
          1. A desktop example
          2. Web applications
        5. Oversized images
          1. Image resolution
          2. Image format
        6. Summary
      12. 4. Addressing Network Performance
        1. Internet protocols
          1. TCP/IP
            1. Slow-start
          2. HTTP
            1. Headers
            2. HTTP methods
            3. Status codes
            4. Encryption
              1. Key exchange
              2. Delay diagnostics
              3. Performance tweaks
            5. HTTP/2
            6. WebSockets
        2. Compression
          1. Lossless compression algorithms
          2. Bundling and minification
            1. Bundling
            2. Minification
            3. Changes in ASP.NET Core
          3. Image optimization
            1. PNG
            2. JPEG
            3. Other image formats
            4. Resizing images
        3. Caching
          1. Browser
          2. Server
          3. Proxy servers between you and your users
            1. CDNs
        4. Summary
      13. 5. Optimizing I/O Performance
        1. Input/output
          1. Categories of I/O
            1. Disks
            2. Virtual file systems
            3. Databases
            4. APIs
          2. Network diagnostics tools
            1. Ping
            2. Tracert
            3. Nslookup
            4. Build your own
        2. Solutions
          1. Batching API requests
          2. Efficient DB operations
            1. Database tuning
            2. Reporting
              1. Aggregates
              2. Sampling
            3. Inserting data
              1. GUIDs
            4. Advanced DB topics
        3. Simulation and testing
        4. Summary
      14. 6. Understanding Code Execution and Asynchronous Operations
        1. Getting started with the core projects
          1. .NET Core
          2. ASP.NET Core
            1. Kestrel
        2. Data structures
          1. Lists
          2. Dictionaries
          3. Collection benchmarks
          4. Bloom filters
        3. Hashing and checksums
          1. Hashing benchmarks
        4. Serialization
        5. SIMD CPU instructions
        6. Parallel programming
          1. Task Parallel Library
          2. Parallel LINQ
          3. Parallel benchmarking
          4. Parallel programming limitations
        7. Practices to avoid
          1. Reflection
          2. Regular expressions
          3. String concatenation in tight loops
          4. Dynamic typing
          5. Synchronous operations
          6. Exceptions
        8. Summary
      15. 7. Learning Caching and Message Queuing
        1. Why caching is hard
          1. Web caching
            1. Caching background
              1. HTTP headers
              2. Cache busting
            2. Service workers
              1. Service worker example
            3. Web and proxy servers
              1. IIS
              2. Varnish
            4. Working with a content delivery network
            5. When not to cache
          2. Application layer caching
            1. Redis
            2. Database result set caching
        2. Message queuing
          1. Coffee shop analogy
          2. Message queuing styles
          3. Common messaging patterns
            1. Unicast
            2. Pub/sub
          4. RabbitMQ
          5. Queuing frameworks and libraries
        3. Summary
      16. 8. The Downsides of Performance-Enhancing Tools
        1. Managing complexity
          1. Understanding complexity
          2. Complexity reduction
            1. Frameworks
            2. Architecture
              1. Monolith versus microservices
              2. Architecture comparison
            3. Refactoring
        2. A culture of high performance
          1. A blameless culture
          2. Intellectual dishonesty
          3. Slow down to go faster
          4. From the ground up
          5. Shared values
        3. The price of performance
        4. Distributed debugging
          1. Logging
            1. Error logging
            2. Application Insights
            3. Integrated logging
            4. Centralized logging
          2. Statistics
        5. Managing stale caches
        6. Summary
      17. 9. Monitoring Performance Regressions
        1. Profiling and measurement
        2. Testing
          1. Automated testing
          2. Continuous integration
          3. Slow testing
          4. Fixing performance regressions
          5. Load testing
          6. Realism
            1. Realistic environments
            2. Realistic workloads
              1. Feature switching
          7. Experimenting for science
          8. A/B testing
          9. User interface testing
            1. Web UI testing tools
            2. Automating UI performance tests
        3. Staying alert
        4. DevOps
          1. DevOps tooling
            1. Provisioning
            2. Monitoring
        5. Hosting
        6. Summary
      18. 10. The Way Ahead
        1. Reviewing what we learned
        2. Further reading
          1. Going native
          2. Processor architecture
          3. Hardware is hard
          4. Machine learning
          5. Big data and MapReduce
          6. Orleans
          7. Custom transports
          8. Advanced hashing
        3. Library and framework support
        4. The future
        5. Summary