And yet more

Programming Microsoft Azure Service Fabric by Haishi Bai

I’ve been doing a lot of Kubernetes lately, and since that has a Google heritage from systems like Borg, I thought it was probably time to have another quick look at Service Fabric which was/is the base layer for many Microsoft services. Unsurprisingly, the concepts in Service Fabric are every much like those you find in other systems, though it felt to me that there was more of an emphasis on sharding and actor patterns – I think that some of these ideas have been taken across to Kubernetes with Microsoft’s DAPR. In Service Fabric the services can be stateful or stateless, and there are the usual mechanisms for rolling out changes across a cluster, concepts of scalability and performance, and availability and reliability.

The later chapters on Linux containers and advanced concepts (serverless and artificial intelligence) felt like standard expected things these days, but were probably innovative when the first version of the book was written.

Linux Kernel Programming: A Comprehensive guide to kernel internals, writing kernel modules and kernel synchronization by Kaiwan N Billimoria

This is a big thick book on the Linux kernel and how to write modules to plug into the kernel. As a way to write these kernel modules, it covers the memory management inside the kernel and the way it handles threads in great detail. For the former, you’ll get to understand the mappings of virtual memory and the page tables, on the way to understanding where your modules should allocate their memory. For the latter, you’ll get a great understanding of the Linux tasks and how they are scheduled, and the locks you will need to use to make your code race free.

The book is really practical, with instructions on how to set up virtual box to safely set up many of the kernel programming exercises.

I absolutely loved this book, and will be spending time working on the examples to increase my understanding.

Designing Microservices Platforms with NATS by Chanaka Fernando

We’ve been using NATS as a message bus at work in an application that I have inherited, so I wanted to learn a little more about it. This book covers the NATs application in its early chapters but also covers the ideas behind Microservice architectures too. It was an interesting read.

Posted in Uncategorized | Leave a comment

Another set of books

React Hooks In Action: With Suspense and Concurrent Mode by John Larsen

I’d been away from React for a while and noticed that React 18 has just been released. This reminded me of the talk about Concurrent mode (the ability for a render to be interrupted and then restarted if a higher priority task comes along) and Suspense (seamlessly handle data loading notification in the GUI) a while back when I last did React in my day job.

This book is a great guide to modern React. It discusses what hooks are and how they work, and then walks through an example application that uses a number of the standard React hooks. The application feels really realistic and the author explains the needs for the hooks and how to use them really well – useState, useReducer (part of the eternal question of how to handle component state across the application), useEffect and useRef. There is an initial chapter on managing application state which introduces useCallback and then useMemo.

This section then ends with chapters on managing state with the Context Api, creating your own hooks (by putting together existing hooks, and at the same time respecting the Rules of Hooks), and then a discussion of some of the available third party hooks (and React Query).

The shorter part 2 of the book covers Suspense and Concurrent Mode. The former is introduced in a chapter that covers lazy loading and error boundaries, and then there is a chapter on data fetching and how it interacts with Suspense. The last chapter looks at Concurrent Mode and the future of React.

The book is great – it is just the right length and covers the material in a way that answers most of the first level questions. Highly recommended!

Learning GraphQL – Declarative Data Fetching for Modern Web Apps by Eve Porcello and Alex Banks

Using REST to fetch data from a complicated data model feels increasingly like hard work for the client. There are often lots of times when you fetch an object and then need to issue requests for each of the children, wiring the navigation of the object graph by doing a fetch for each edge. It has often felt to me like a single request with more specifics about the navigation of the graph to the desired properties was the way to go and things like OData and GraphQL offer this.

This books is short introduction to GraphQL. It starts by describing where GraphQL fits in, with a discussion of the issues with REST. There’s a very brief introduction to graph theory and then a chapter on the GraphQL language – this covers fragments, mutations and subscriptions (GraphQL is not just for reading data but allows applications to write data, and also allows you to keep listening and be informed when the data changes).

There is a chapter on schemas, and then an example of how to implement a schema using Apollo Server, an open source GraphQL library. The book finishes with chapters on GraphQL clients (particularly Apollo Client) with some focus on their caches. The last chapter covers GraphQL in the real world, discussing things like timeouts and security, as well as community resources you can access.

The book is short, but provides all the information that you need.

Posted in Uncategorized | Leave a comment

Software Architecture: It’s hard!

Software Architecture: The Hard Parts – Modern Trade-off Analysis for Distributed Architectures by Neal Ford, Mark Richard, Pramod Sadalage and Zhamak Dehghani

This is a good book about the hard architectural decisions that a team face when breaking a monolith into a micro-services architecture. It covers a lot of very interesting topics like architectural fitness functions and is full of lots of practical advice on how to weigh up the pro and cons. I’m not sure I’m the greatest fan of the storyline which follows a team as it splits up a support application from monolith to microservices, but all of the material that hangs off the chapters of this story is really good. The book covers everything from choice of database type to service granularity to the different types of transactional sagas to choices between choreography and orchestration. It’s a great read.

Posted in Uncategorized | Leave a comment

Ceph in detail

Mastering Ceph: Infrastructure storage solutions with the latest Ceph release by Nick Fisk

We’ve started using Ceph, or more specifically Rook-Ceph as a storage solution for some Kubernetes work that we are doing. We started treating Ceph itself as a bit of a black box, but as we’ve moved more towards the performance side of things, it has become apparent that we need to have a better understanding of what is happening under the covers.

This book is a little old, but does give a good understanding of Ceph. There are general overview chapters about Ceph, and what its unique selling points are, and there are some Vagrant scripts that allow you to do a Ceph deployment yourself, in a couple of different scenarios. I loved the way that the book gets into the details by getting you to run various command line commands to understand what is going on. The second section of the book is about operating and tuning Ceph, and gave us many insights as to what was happening beneath the covers, and Section 3 on troubleshooting is going to come in useful as we deploy our K8s application to more customer sites.

For us, some parts of the book weren’t particularly relevant, as we won’t be using CephFS for example, but the book is definitely worth a read if you want to see across the whole of the Ceph system. We still have many questions about how Ceph is driven via Rook in the K8s world, but this was a great way to understand the storage architecture.

Posted in Uncategorized | Leave a comment

What are the chances of that?

I put together a lightning talk on Quantum Computing. I’ve recently got into Quantum Computing and find it a fascinating subject. There was, of course, too much material to fit in to the talk – I was aiming to try and cover all of the misconceptions about Quantum Computing, but in the end there was just too much to cover to make this really the subject of the talk.

Posted in Uncategorized | Leave a comment

Secure your containers

Container Security by Liz Rice

I really enjoyed this book which takes you through container security. It starts with a good introduction on container security threats, including security boundaries and the issue of multi-tenancy. After that, we look at some of the security mechanisms that Linux offers – systems calls and permissions including capabilities and features like setuid and setgid. This is followed by a good chapter on cgroups and how they can be used to control resource usage for a group of processes. The author then goes through the means that Docker uses to isolate its containers – the various Linux namespaces, the how the root is changed to isolate the container’s filesystem from the outside world.

There’s a great chapter on virtual machines, with a discussion of the difference between Type I and Type II VMs and how they work. This discusses how they differ from containers. This is followed by a chapter on container images – in particular what they contain in the various layers. We then look at what vulnerabilities images can contain, and how we can use scanning to detect them. Linux mechanisms to tighten container isolation are then covered – tools like Seccomp, AppArmour, SELinux and gVisor, and then moving away from containers to Kata Containers, FireCracker and Unikernels.

Chapters follow on breaking container isolation which includes running rootless containers, and the use of the –privileged flag. Then a chapter on container network security, one on TLS, how to pass secrets securely to containers, and container runtime protection using profiles.

This is quite a short book which is packed with loads of information. I really enjoyed the “build your own docker” chapters to build up knowledge about the way containers work, and the explanations are really great.

Posted in Uncategorized | Leave a comment

Microsoft Refresh

I was interested in the details behind Microsoft’s move into cloud computing, and was hoping that these two books would give me some of the story. Unfortunately, neither did.

Hit Refresh by Satya Nadella

This book didn’t really work for me as an autobiography, and didn’t work as a story of how Microsoft was rebooted. None of the discussion about the future, via Artificial Intelligence and Quantum Computing really went into anything like the detail I was looking for either.

The Microsoft Story by Dan Good

The book did a good job of describing the Microsoft Story in some detail, and I must admit that I hadn’t heard some of the stories before. Again, not a bad read, but it stops short of the era of Microsoft that I wanted details about.

Posted in Uncategorized | Leave a comment

Getting to grips with Quantum Computing

Learn Quantum Computing with Python and Q# by Sarah Kaiser and Christopher Grande

This is an absolutely fantastic book.

Quantum computers might well be the next step in speed and computing power, and I wanted an introduction that would teach me how it all links together. This book comes at the subject from a very practical perspective, and as I’ve always been a great believer that you don’t really understand something until you implement it yourself, and since I can’t afford to build a quantum computer, building a simulator like you do in the early chapters of this book is a great way to see what is happening.

The book starts with an introductory chapter on quantum computers and covers how they different from classical computers. Then things start getting interesting. The book looks at Qubits, and how they are the building block of quantum algorithms. We quickly start writing a simulator in Python. The whole time the authors push the linear algebra side of things, showing us the various transforms (using Real numbers to start with). As initial targets of the first version of the simulator, we look at quantum key distribution, and then get into non-local games which requires us to use multiple qubits. Part 1 finishes with simulation of quantum teleportation and entanglement. We start using NumPy and move to using the QuTiP library as things become more complicated to simulate.

Part 2 of the book moves on to using Q# as the implementation language – you can find many other examples here. The book does a good job of covering the Q# language, and then talks through some quantum algorithms like Deutsch-Jozsa to convert an oracle into a quantum operation. Solving various games is used as the motivator for some of the examples – I think that was a fun way to set up a problem, but it did take a little getting used to.

Part 3 of the book looks at some applications of a Quantum computer. Applications in chemistry by simulating the Hamiltonian for a molecule, applications in search by way of Grover’s algorithm, and then integer factoring using Shor’s algorithm. The authors walk through the algorithms leaving you with a good understanding of how they work.

I’ll say it again – this is a really great book for getting up to speed on Quantum computing, and I enjoyed it very much.

Posted in Uncategorized | Leave a comment

Python for the win

I’ve been using Python a lot for personal programming projects. The REPL makes it fun to explore a problem space and the number of libraries is truly astounding.

CPython Internals: Your Guide to the Python 3 Interpreter by Antony Shaw

I got interested in the internals of Python, after coming across the proposal by Sam Gross in Multithreaded Python without the GIL to change the reference counting to avoid some of the locking that is currently required, and change the core to allow more than one thread to run Python at the same time. The GIL has always been something that made Python look a lot less useful as a runtime, though admittedly, as the next book shows, people have had to come up with a mass of clever ideas to work around it.

This book was a great practical introduction to the internals of CPython. The first chapter gets you to check out the sources, and then build them using a number of development environments. The next chapters cover the grammar, the lexing and parsing and the resulting syntax trees, and then move on to the implementation of the compiler. The book then goes into some detail about the evaluation loop, including the stack frames and thread states, and then dives into chapters on memory management, parallelism and concurrency, and objects and types. The last chapters cover the standard library, the test suite and benchmarking/profiling/tracing.

The book goes into the right amount of detail, at times stepping us through the actions of the runtime so we understand what is happening. It also covers how you can use C modules from Python.

High Performance Python: Practical Performant Programming for Humans by Micha Gorelick and Ian Ozsvald

This is a lovely book, full of techniques to improve the performance of Python code. There’s an initial chapter giving an overview of the Python system, followed by a chapter on how to profile to find the bottlenecks. The authors then look at some common datatypes in the next chapters – list/tuples, dictionaries/sets and iterators/generators. Matrices and vectors are important datatypes in machine learning, and there is a chapter about the various libraries and tricks to get good performance. The next chapters cover the various ways to compile Python in to C code, including Cython and PyPy. Three chapters follow on scaling up to use the multiple cores on the machine – an in-depth look at AsyncIO, the multiprocessing module and clusters and job queues. It is quite amazing the ways people have developed to get around the GIL to make applications scale as you add more cores.

The book then has a chapter on how to use less RAM, including some techniques for approximating results to use less memory. The last chapter is a series of case studies on optimising Python applications in the real world.

This was a thoroughly interesting book, giving insights into the implementation as well as ways to work around the limitations. Some of the advice is general and is valid for all programming languages and runtimes.

Posted in Uncategorized | Leave a comment

Dynamic and profile guided

Another lightning talk at work, this time on Dynamic Profile Guided Optimization. The idea that you optimize your running program specifically for the data to which it is being applied, has always felt to me like the right way to do things. It’s all very well optimizing for the general case, or collecting data on runs across some scenarios and using that to guide the compilation, but surely the best solution is to optimize hard for the data you’ve seen so far during the run, with the likely hypothesis that subsequent data will be like that too. .NET seems to have taken ages to catch up with other platforms like Java that have had this technology for some time. With the new tiered compilation model, this fits in quite nicely and with some initial work on OSR making it possible to optimize running functions, there must be many gains to be made in the future.

Posted in Uncategorized | Leave a comment